可以按照我的設計思路幫我檢查一下代碼嗎
<!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 myopen=confirm("是否新窗口打開網站");
??? // 新窗口打開時彈出確認框,是否打開
???
??? if(myopen==true)
??? {
??????? var myweb=prompt("請輸入你要打開的網址");
??????? // 通過輸入對話框,確定打開的網址,默認為 http://www.xianlaiwan.cn/
???????
??????? if(myweb!=null)
??????? {window.open(myweb,"_blank","width=400,height=500,menubar=no,toolbar=no");
??????? }
??????? else
??????? {window.open("http://www.xianlaiwan.cn/","_blank","width=400,height=500,menubar=no,toolbar=no")}
??????? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
???????
??? else
??? {document.write("慕課網功能很強大,可以嘗試打開哦~http://www.xianlaiwan.cn/")}
??? }?
? </script>
?</head>
?<body>
?? <input type="button" value="新窗口打開網站" onclick="openWindow()" />
?</body>
</html>
2016-10-14
if(myopen==true),這個感覺是沒有錯的,confim消息對話框語法就是==
2016-10-14
??
?else?{window.open("http://www.xianlaiwan.cn/","_blank","width=400,height=500,menubar=no,toolbar=no")}
這段和if(myweb!=null)的重復了。
還有就是if(myopen==true),為什么有兩個"="號?
?還有這一段"var myweb=prompt("請輸入你要打開的網址");"網址是要在括號里面填寫,這樣寫var myweb=prompt("請輸入你要打開的網址","http://www.xianlaiwan.cn/");。同樣是這段代碼,你把http后面的“:”寫成了中文下的”:“。
最后提示:寫代碼的時候一定要區分中英文的寫法。
貼上我幫你修改過的代碼,按照你的思路改的。
?function openWindow()
?{
????var myopen=confirm("是否新窗口打開網站");?// 新窗口打開時彈出確認框,是否打開
? ??????if(myopen=true)
????????{
? ? var myweb=prompt("請輸入你要打開的網址","http://www.xianlaiwan.cn/");
? ? ? ? // 通過輸入對話框,確定打開的網址,默認為 http://www.xianlaiwan.cn/
? ? ?????if(myweb!=null)
?????{window.open(myweb,'_blank','width=400,height=500,menubar=no,toolbar=no');}
? ? ? ? /* else?{alert("慕課網功能很強大,可以嘗試打開哦~http:www.xianlaiwan.cn/");}*/
? ? ? ? else
? ? ? ?{document.write("慕課網功能很強大,可以嘗試打開哦~http://www.xianlaiwan.cn/");}
? ? ? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ???????} ? ??
? ? else
? ? {alert("再見!");}
? ? } ?