最符合要求的編輯
我覺(jué)得最符合左邊三點(diǎn)要求的話,使用prompt和IF else就可以了,如以下我的編輯;
但是看下面很多人編寫(xiě)的都使用了confirm,來(lái)返回true和null,請(qǐng)問(wèn)怎樣才是最符合標(biāo)準(zhǔn)又簡(jiǎn)潔的代碼呢,
歡迎討論指正,謝謝
我覺(jué)得最符合左邊三點(diǎn)要求的話,使用prompt和IF else就可以了,如以下我的編輯;
但是看下面很多人編寫(xiě)的都使用了confirm,來(lái)返回true和null,請(qǐng)問(wèn)怎樣才是最符合標(biāo)準(zhǔn)又簡(jiǎn)潔的代碼呢,
歡迎討論指正,謝謝
2018-07-19
舉報(bào)
2018-07-19
提示:
要求第一條是要你確定是否打開(kāi)新窗口,所以需要使用confirm來(lái)確定。
<!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 mymessger=confirm("是否打開(kāi)新窗口:");
? ? // 新窗口打開(kāi)時(shí)彈出確認(rèn)框,是否打開(kāi)
if(mymessger==true){
? ? // 通過(guò)輸入對(duì)話框,確定打開(kāi)的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
var myWin=prompt("請(qǐng)輸入你要打開(kāi)的網(wǎng)站網(wǎng)址:");
? ? //打開(kāi)的窗口要求,寬400像素,高500像素,無(wú)菜單欄、無(wú)工具欄。
? ? if(myWin!=null){
? ? window.open(myWin,'_blank','width=400,height=500,menubar=no,toolbar=no');
}
}
}
? </script>?
?</head>?
?<body>?
? <input type="button" value="新窗口打開(kāi)網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>