MVP慕粉
2017-06-24 20:24
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script>
function open(){
var win=confirm('你确定打开这个窗口吗?')
if(win==true){
var win1=prompt('打开下面默认的网址?','http://www.imooc.com')
if(win1!=null){
window.open(win1,'_blank','width=300,height=500,toolbar=no,scrollbars=yes,status=no,menubar=no')}
else{alert('byebye')}
}
else{alert('see you')}
}
</script>
</head>
<body>
<input type="button" value="点击我,打开新窗口" onClick="open()"/>
</body>
</html>
把你定义的open函数换个名字,比如open_window,你的open与js的open冲突了。望采纳!
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>无标题文档</title> <script> function open_window(){ var win=confirm('你确定打开这个窗口吗?') if(win==true){ var win1=prompt('打开下面默认的网址?','http://www.imooc.com') if(win1!=null){ window.open(win1,'_blank','width=300,height=500,toolbar=no,scrollbars=yes,status=no,menubar=no')} else{alert('byebye')} } else{alert('see you')} } </script> </head> <body> <input type="button" value="点击我,打开新窗口" onClick="open_window()"/> </body> </html>
你每个语句后面的;呢
win1是否为空用!==判断吧
JavaScript入门篇
739817 学习 · 9566 问题
相似问题