<!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 open=confrim("是否打开"); if (open==true){ var ulr=prompt("请输入网址","http://www.imooc.com/"); if (ulr==true){ window.open(ulr,"_blank",'windth=400px,hight=500px,menuber=no,toolber=no'); } else{ alert("再见"); } } else{ alert("再见"); } } </script> </head> <body> <input type="button" value="新窗口打开网站" onclick="openWindow()" /> </body></html>
3 回答
qq_青枣工作室_0
TA贡献446条经验 获得超754个赞
var open=confrim("是否打开"); // 单词拼写错误,应该是 confirm
if (open==ture){ // 单词拼写错误,应该是 true
if (ulr==ture){ // 单词拼写错误,而且字符串不能直接用==true判断,应该直接写: if(ulr) {
修正后:
<!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 open=confirm("是否打开"); if (open==true){ var url=prompt("请输入网址","http://www.imooc.com/"); if (url){ window.open(url,"_blank",'windth=400px,hight=500px,menuber=no,toolber=no'); } else{ alert("再见"); } } else{ alert("再见"); } } </script> </head> <body> <input type="button" value="新窗口打开网站" onclick="openWindow()" /> </body> </html>
添加回答
举报
0/150
提交
取消