我想打开两个内部和一个外部的onclick两个页面

时间:2016-02-04 08:18:12

标签: javascript html

你能告诉我如何在这段代码上修复它吗?这里我有两个内部代码和两个外部(到youtube)

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>LS_model</title>
<link href="ls.css" rel="stylesheet">
<link href="index.css" rel="stylesheet">
</head>
<body>
<div id="space"><br></div>
<div id="container">
<div id="wb_Image1" style="position:absolute;left:62px;top:291px;width:876px;height:524px;z-index:0;">
<img src="images/Background.png" id="Image1" alt=""></div>
<div id="wb_Image2" style="position:absolute;left:75px;top:31px;width:840px;height:260px;z-index:1;">
<img src="images/ads.gif" id="Image2" alt=""></div>
<div id="wb_Image3" style="position:absolute;left:126px;top:343px;width:140px;height:57px;z-index:2;">
<a href="#" onclick="window.location.href='./page22.html';window.open('https://www.youtube.com/watch?v=5u7ytZmxstY');return false;"><img src="images/videoss-b.gif" id="Image3" alt=""></a></div>
<div id="wb_Image4" style="position:absolute;left:723px;top:344px;width:140px;height:56px;z-index:3;">
<a href="#" onclick="window.location.href='./page1.html';window.open('https://www.youtube.com/watch?v=5u7ytZmxstY');return false;"><img src="images/Photos-b.gif" id="Image4" alt=""></a></div>
</div>
</body>
</html>

2 个答案:

答案 0 :(得分:1)

试试这个

使用window.open打开两个页面,然后从代码中删除 return false

<a href="#" onclick="window.open('./page1.html');window.open('https://www.youtube.com/watch?v=5u7ytZmxstY');"><img src="images/Photos-b.gif" id="Image4" alt=""></a>

答案 1 :(得分:0)

要在新标签页中打开,请使用:

window.open('https://www.youtube.com/watch?v=5u7ytZmxstY', '_blank');

要打开内部,请使用:

window.open('https://www.youtube.com/watch?v=5u7ytZmxstY');