在html中添加img src标记的click事件

时间:2022-06-04 09:28:56

I am new in HTML,

我是HTML新手,

I have 2 HTML pages page1 and Page2

我有2个HTML页面page1和Page2

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>

On click of last img (src="IOS_landing_V02_05.jpg") i want to load another HTMl page i.e Page2

点击上一个img(src =“IOS_landing_V02_05.jpg”)我想加载另一个HTMl页面,即Page2

How to do this ?

这该怎么做 ?

4 个解决方案

#1


Wrap the last img inside a link like this :

将最后一个img包装在这样的链接中:

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

Now clicking on it, will load page2.

现在点击它,将加载page2。

#2


Wrap your img tag with a anchor tag that will redirect you.

使用会重定向您的锚标记包裹您的img标记。

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

#3


you can do it this way: Wrap your image with <a> tag, then add a link to your second page using the href attribute.

您可以这样做:使用标签包裹图像,然后使用href属性添加指向第二页的链接。

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

#4


First set on 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>

#1


Wrap the last img inside a link like this :

将最后一个img包装在这样的链接中:

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

Now clicking on it, will load page2.

现在点击它,将加载page2。

#2


Wrap your img tag with a anchor tag that will redirect you.

使用会重定向您的锚标记包裹您的img标记。

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

#3


you can do it this way: Wrap your image with <a> tag, then add a link to your second page using the href attribute.

您可以这样做:使用标签包裹图像,然后使用href属性添加指向第二页的链接。

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

#4


First set on 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>