為什么一直不停地彈confirm對話框?
輸入如下圖1部分的代碼,點(diǎn)擊“確定“按鈕,出現(xiàn)prompt消息對話框后,點(diǎn)擊“確定”,一直彈如圖2的confirm對話框,為什么無法打開新的網(wǎng)址呢?這是什么原因?qū)е碌模?/p>
輸入如下圖1部分的代碼,點(diǎn)擊“確定“按鈕,出現(xiàn)prompt消息對話框后,點(diǎn)擊“確定”,一直彈如圖2的confirm對話框,為什么無法打開新的網(wǎng)址呢?這是什么原因?qū)е碌模?/p>
2016-05-04
舉報(bào)
2016-05-04
<!DOCTYPE html>
<html>
?<head>
? <title> new document </title> ?
? <meta http-equiv="Content-Type" content="text/html; charset=gbk"/> ??
? <script type="text/javascript"> ?
? ??
? ? // 新窗口打開時(shí)彈出確認(rèn)框,是否打開
? ? // 通過輸入對話框,確定打開的網(wǎng)址,默認(rèn)為 http://yifanck.cn/
? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ? function openWindow(){
?var mymessage=confirm("是否打開新的網(wǎng)頁?");
?if(mymessage==true)
?{
? ? ?var myurl=prompt("請輸入網(wǎng)址",'http://yifanck.cn/');
?if(myurl!=null)
?{
? ? ?window.open(myurl,'_blank','width=400,height=500,menubar=no,toolbar=no');
?}
?}
}
? ??
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
原樣照抄你的,打上去沒問題
P.S. 注意中英文輸入法的引號區(qū)別
2016-05-04
什么瀏覽器啊
2016-05-04
confirm返回的是boolean類型的,直接if(mymessage)