艾离
2015-08-08 17:44
<!DOCTYPE html>
<html>
<head>
<title> new document </title>
<meta http-equiv="Content-Type" content="text/html; charset=gbk"/>
<script type="text/javascript">
var js1=confirm("确定打开网页?");
if(js1==true)
var js2=prompt("请输入网址(仅限1.百度,2.淘宝,3.慕课)");
if(js2==1)
window.open('http//www.baidu.com','_blank','height=500px,width=400px,');
if(js2==2)
window.open('http//www.baidu.com','_blank','height=500px,width=400px,');
if(js2==3)
window.open('http//www.baidu.com','_blank','height=500px,width=400px,');
/* */
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="js1" />
</body>
</html>
这个哪里出问题了呀?请指教
还有,你的onclick="js1"也是无效的,因为变量不能充当方法,还是得老老实实地定义function js1(){}
亲,你代码里所有的http//www.baidu.com都是无效的,应该是http://www.baidu.com,少了冒号
JavaScript入门篇
741115 学习 · 9865 问题
相似问题