不知道為什么不行,求解答
<!DOCTYPE html>
<html>
?<head>
? <title> new document </title>??
? <meta http-equiv="Content-Type" content="text/html; charset=gbk"/>? ?
? <script type="text/javascript">??
? ??
? ? // 新窗口打開(kāi)時(shí)彈出確認(rèn)框,是否打開(kāi)
? ?
? ? // 通過(guò)輸入對(duì)話框,確定打開(kāi)的網(wǎng)址,默認(rèn)為 http://yifanck.cn/
? ? //打開(kāi)的窗口要求,寬400像素,高500像素,無(wú)菜單欄、無(wú)工具欄。
? ? ?
? ? ?function openWindow()
? ? {? ?
? ? ? ? var mymessage = confirm('是否打開(kāi)');
? ? ? ? if (mymessage == true)
? ? ? ? {
? ? ? ? ? ? var new =? prompt("are you sure you want to open it?")
? ? ? ? ? ? if (new == 'sure')
? ? ? ? ? ? {
? ? ? ? ? ? window.open('http://yifanck.cn/','_blank','width=400, height=500, menubar=no,toolbar=no');
? ? ? ? ? ? }
? ? ? ? }
? ? ? ??
? ? }
? ??
? </script>?
?</head>?
?<body>?
? <input type="button" value="新窗口打開(kāi)網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
2019-07-03
?prompt的判定問(wèn)題,取消你的new==null? ?確定你的new!=null
并且認(rèn)為要求網(wǎng)址可以自己輸入,只是默認(rèn)http://yifanck.cn
所以應(yīng)該是
2019-06-28
? function openWindow()
??? {
??? var mymessage=confirm("是否打開(kāi)新窗口?");
??? if(mymessage==true)
??? {? var mywin=window.open('http://yifanck.cn','_blank','width=400,heigh=500,menubar=no,toolbar=no')?? }??
??? else
??? {? mywin.close();?? }
? ? ? ??
??? }
題目上說(shuō)是“使用 if 判斷確認(rèn)框是否點(diǎn)擊了確定”, 而不是輸入確定,所以不需要用prompt彈出消息對(duì)話框(包含一個(gè)確定按鈕、取消按鈕與一個(gè)文本輸入框),而是直接用confirm彈出對(duì)話框(包含一個(gè)確定,一個(gè)取消按鈕),他倆的區(qū)別就是prompt消息對(duì)話框有文本輸入框,而這里不需要輸入,而是直接點(diǎn)擊“確定”。?