Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/472.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在html中添加img src标记的单击事件_Javascript_Html - Fatal编程技术网

Javascript 在html中添加img src标记的单击事件

Javascript 在html中添加img src标记的单击事件,javascript,html,Javascript,Html,我是HTML新手 我有两个HTML页面page1和Page2 第1页: <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" m

我是HTML新手

我有两个HTML页面
page1
Page2

第1页:

<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>

IOS_着陆_V02
单击最后一个img
(src=“IOS\u landing\u V02\u 05.jpg”)
我想加载另一个HTMl页面,即
Page2


如何做到这一点?

a
锚定标记将
img
标记包裹起来,该锚定标记将重定向您

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

你可以这样做:用
将最后一个
img
包装在如下链接中:

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


现在单击它,将为您的图像加载
page2

第一次设置单击事件,如下所示:

<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>

//头部功能
函数Previewmode()
{
//加载新的html页面
窗口打开(“http://newpage.html");   
}   

使用锚定标记将最后一幅图像包裹起来,href指向第二页如果需要链接,请在图像周围使用链接标记。还是需要javascript“onClick”?
<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>