Add img src tag click event to html

I am new to HTML,

I have 2 HTML pages page1

andPage2

Page1:

<html>
<head>
<title>IOS_landing_V02</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<!-- Save for Web Slices (IOS_landing_V02.psd) -->
<table id="Table_01" width="1024" height="768" border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td>
            <img src="IOS_landing_V02_01.jpg" width="1024" height="20" alt=""></td>
    </tr>
    <tr>
        <td>
            <img src="IOS_landing_V02_02.jpg" width="1024" height="112" alt=""></td>
    </tr>
    <tr>
        <td>
            <img src="IOS_landing_V02_03.jpg" width="1024" height="422" alt=""></td>
    </tr>
    <tr>
        <td>
            <img src="IOS_landing_V02_04.jpg" width="1024" height="1" alt=""></td>
    </tr>
    <tr>
        <td>
            <img src="IOS_landing_V02_05.jpg" width="1024" height="213" alt=""></td>
    </tr>
</table>
<!-- End Save for Web Slices -->
</body>
</html>

      

When the last img is clicked (src="IOS_landing_V02_05.jpg")

I want to load another HTMl ie pagePage2

How to do it?

+3


source to share


4 answers


Wrap the latter img

inside a link like this:

<a href="pathToPage2.html">
  <img src="IOS_landing_V02_05.jpg" width="1024" height="213" alt="">
</a>

      



Now clicking on it will load page2

.

0


source


Wrap the tag img

with an anchor tag a

that will redirect you.



<a href="page2.html"><img src="IOS_landing_V02_05.jpg" width="1024" height="213" alt=""></a>

      

0


source


you can do it like this: wrap the image with a tag <a>

and then add a link to the second page using an attribute href

.

<td>
        <a href="page2.html">  
            <img src="IOS_landing_V02_05.jpg" width="1024" height="213" alt="">  
       </a>  
</td>

      

0


source


First, set the click event for your image like this:

<img src="IOS_landing_V02_05.jpg" width="1024" height="213" alt="" onclick='newhtml()'>

// Function in head part
<script>
function Previewmode()
{
// load new html page
   window.open("http://newpage.html");   
}   
</script>

      

0


source







All Articles