<!DOCTYPE html><html> <head> <title> new document </title> <meta http-equiv="Content-Type" content="text/html; charset=gbk"/> <script type="text/javascript"> function openWindow(){ var mymessage=confirm("你确定要打开新窗口吗?"); if(mymessage==true) {var mynum=prompt("输入网址:","http://www.imooc.com/"); if(mynum!=null) {window.open('mynum','_blank','width=400,height=500,menubar=no,toolbar=no,status=yes,scrollbars=yes');} else{alert("返回");} else{alert("返回");} } </script> </head> <body> <input type="button" value="新窗口打开网站" onclick="openWindow()" /> </body></html>
2 回答
kofzxaaa
TA贡献66条经验 获得超26个赞
额,你那个'mynum'把单引号去掉即可。
参考代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openWindow()" />
<script>
function openWindow(){
var mymessage=confirm("你确定要打开新窗口吗?");
if(mymessage==true)
{
var mynum=prompt("输入网址:","http://www.imooc.com/");
if(mynum!=null)
{
window.open(mynum,'_blank','width=400,height=500,menubar=no,toolbar=no,status=yes,scrollbars=yes');
}
// else{alert("返回");}
//else{alert("返回");}
}
}
</script>
</body>
</html>还有你少了个}。
添加回答
举报
0/150
提交
取消
