問一下哪里錯了,彈不出來
<!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("請輸入網址")
? ? if (url!null)
? ? {window.open(url,'_blank','width=400,height=500')
? ? else
? ? {window.open('http://www.xianlaiwan.cn','_blank','width=400,height=500')
? ? }
? ? }
? ? }
? ? }
? ??
? ??
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網站" onclick="openWindow()" />?
?</body>
</html>
2018-10-29
1,url后面應該是一個等號,
2,好像是if的嵌套導致的問題
3,第二個if少一個 右大括號 }
希望能幫助你!
2018-10-29
? <script type="text/javascript">??
? ? function openWindow(){
? ? // 新窗口打開時彈出確認框,是否打開
? ? var ifopen=confirm("是否確認打開窗口?")
? ? if(ifopen==true)
? ? ? ? {
? ? ? ? // 通過輸入對話框,確定打開的網址,默認為 http://www.xianlaiwan.cn/
? ? ? ? ? ? var url=prompt("請輸入網址,默認為慕課網")
? ? ? ? ? ? if(url==''){
? ? ? ? ? ? ? ? url="http://www.xianlaiwan.cn/"
? ? ? ? ? ? }
? ? ? ? ? ? window.open(url,'_blank','width=400,height=500','menubar=no','toolbar=no');
? ? ? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ? ? ? }
? ? }
? </script>?
僅供參考