怎么能讓消息對話框prompt點擊取消后不跳轉(zhuǎn)網(wǎ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 a=confirm("是否打開?");
if(a==true)
{var b=prompt("確定打開的網(wǎng)址","http://idcbgp.cn/");window.open('http://idcbgp.cn/','_blank',width=400,height=500)}
else
{document.write("再見");}
}
</script>?
?</head>?
?<body>?
? <input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
現(xiàn)在prompt點擊取消也會跳出網(wǎng)頁,怎么能不跳出網(wǎng)頁?
2019-02-11
我試了一下,這個可行
<!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 a=confirm("是否打開?");
if(a==true)
{var b=prompt("確定打開的網(wǎng)址","http://idcbgp.cn/");if (b!=null){window.open('http://idcbgp.cn/','_blank',width=400,height=500);}else{alert("bye");}}
else
{document.write("再見");}
}
</script>?
?</head>?
?<body>?
? <input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
但怎么能讓僅僅輸入該網(wǎng)址時才跳轉(zhuǎn)網(wǎng)頁,輸入別的都無效呢