為什么沒有反應(yīng),還請大神幫忙看看
<!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)
? ? // 新窗口打開時彈出確認(rèn)框,是否打開
? ? {var window=prompt("請輸入網(wǎng)址","idcbgp.cn");
? ? if(window!=null)
? ? // 通過輸入對話框,確定打開的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
{window.open(window,"_blank",'width=400,height=500,menubar=no,tolbar=no');}
? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ? else{ alert("heheheh");}
? ? }
? ? else{ allert("ncjhid");}
? ? }
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
2016-07-03
非常感謝各位大神,終于有反應(yīng)了!
2016-07-02
在這里的變量命名最好不用javascript中的關(guān)鍵字或者保留字,我把你的代碼復(fù)制來運(yùn)行時,有好多語法錯誤,中英文的感嘆號和括號是不行的,這是我運(yùn)行后的代碼截圖,可以打開我們要打開的網(wǎng)頁了~~
2016-07-02
另有小錯:prompt括號內(nèi)逗號為中文逗號
2016-07-02
window為關(guān)鍵字,不要用作變量名