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