慕村9180196
2019-06-06 10:58
我觉得调用两次window.open()就行了,可是点击运行之后,之打开了第一个窗口
function open_win() {
window.open("https://c.runoob.com/","new");
window.open("http://www.runoob.com/","new1");
}
可以使用addEventListener为一个事件绑定多个响应函数
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>window.open</title>
<script type="text/javascript">
window.onload = function(){
var input = document.getElementsByTagName("input")[0];
input.addEventListener("click",function(){window.open("https://c.runoob.com/","new");},false);
input.addEventListener("click",function(){window.open("http://www.runoob.com/","new1");},false);
}
</script>
</head>
<body>
<input name="button" type="button" value="点击我,打开新窗口!" / >
</body>
</html>
点击一个按钮只能打开一个窗口
JavaScript入门篇
741593 学习 · 9869 问题
相似问题