求幫忙看這個(gè)代碼哪里有問題,為什么運(yùn)行不了,主要是confirm這個(gè)框他就彈不出來,非常感謝。
<!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("通過輸入對(duì)話框,確定打開的網(wǎng)址","http://idcbgp.cn")};
? ? // 新窗口打開時(shí)彈出確認(rèn)框,是否打開
if (url=null)
? ? // 通過輸入對(duì)話框,確定打開的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
{window.open("url","width=400","height=500","menubar=no","toolbar=no")
? ? };//打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ? else
? ? alert("googbye")
? </script>?
?</head>?
?<body>?
? <input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
2019-05-14
<!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("通過輸入對(duì)話框,確定打開的網(wǎng)址","http://idcbgp.cn")};
? ? // 新窗口打開時(shí)彈出確認(rèn)框,是否打開
if (url!=null) //判斷條件有問題
? ? // 通過輸入對(duì)話框,確定打開的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
{window.open(url,"width=400","height=500","menubar=no","toolbar=no")//變量不用加""吧
? ? }//大括號(hào)
? ? else{alert("googbye")}
? }//少大括號(hào)
? </script>?
?</head>?
?<body>?
? <input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>