求大神幫我看看,跳轉(zhuǎn)的頁面總是不對
<!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 message=confirm("是否打開網(wǎng)站");
???????
??????? if(message==true)
??????? {
??????????? var pad=window.prompt("通過輸入框,確定打開的網(wǎng)址","http://idcbgp.cn/");
??????????? if(pad==null)
??????????? {window.open(pad,"_blank","height=500,width=400","menubar=no","toolbar=no,");
??????????? }
??????????? else{alert("再見!1");}
??????? }
??????? else{alert("再見!2");}
??? }
??? // 新窗口打開時彈出確認(rèn)框,是否打開
??? // 通過輸入對話框,確定打開的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
??? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
???
???
? </script>
?</head>
?<body>
?? <input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />
?</body>
</html>
第二個彈窗跳轉(zhuǎn)的頁面總是不對啊,點確定跳到了謝謝,點取消會打開一個空白網(wǎng)頁
2019-07-25
? ? ? function openWindow () {
? ? ? ? var ii=confirm("確定要打開嗎");
? ? ? ? if(ii==true){
window.open("http://idcbgp.cn","_blank","width=400,height=500");
? ? ? }else{
? ? ? alert("不打開");
? ? ? }
? ? ? ?}
2019-07-25
第一個問題:var pad=window.prompt("通過輸入框,確定打開的網(wǎng)址","http://idcbgp.cn/");
這句話注意你后邊http后邊的冒號是中文的冒號,改為英文冒號
第二個問題:
這端邏輯寫反了。如果里邊有值應(yīng)當(dāng)執(zhí)行跳轉(zhuǎn),以下正確代碼,望采納
2019-07-25
你寫的代碼是要if(pad==null),是第二個選擇框點取消的時候再打開網(wǎng)頁嗎?如果是的話,你可以再window.open上一行加個alert(pad),pad應(yīng)該是null,所以打不開網(wǎng)頁;
如果你是想第二個選擇框點確定打開網(wǎng)頁,就改成if(pad!=null);
另外,網(wǎng)址是?http://idcbgp.cn,用英文冒號";",不然也打不開網(wǎng)址;