我感覺這樣寫還是有問題!不滿意,想請大佬給出建議
<!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 wahaha=confirm("是否打開世界之門?");
? ? ?if(wahaha==true)
? ? {
? ? document.write("是");
? ? {? ?var haha=confirm("打開世界之門?");
? ? ?if(haha==true)
? ? {document.write("是");
? ? window.open('http://idcbgp.cn ','_blank','width=400,height=500,top=100,left=0')
? ? }
? ? else
? ? {
? ? ? ?wahaha.close();("否");
? ? }
? ? }
? ? }
? ? else
? ? {
? ? ? ?wahaha.close();("否");
? ? }
? }
? ??
? </script>?
?</head>?
?<body>?
? <input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
2019-10-16
//為了你方便看,這里單獨(dú)列出openWindow()的寫法
function openWindow(){
?if(confirm("請確認(rèn)打開窗口"))? ?//因?yàn)閏onfirm的返回值是一個bool量,故可以直接寫在if條件里
{
window.open( prompt("請確認(rèn)網(wǎng)址","http://idcbgp.cn/"),'_blank','width=400,height=500,menubar=no,toolbar=no,scrollbars=yes,status=yes');? ? /*因?yàn)閜rompt的返回值是第二個字符串參數(shù),故默認(rèn)網(wǎng)址寫在第二個字符串參數(shù),以便用戶可以更改(比如改為www.baidu.com)*/
? }
?}
2019-10-16
<!DOCTYPE html>
<html>
?<head>
<script type="text/javascript">
? function openWindow(){
? ? ?if(confirm("請確認(rèn)打開窗口"))//confirm的返回值是一個bool量,故可以直接寫在if條件里
{
window.open( prompt("請確認(rèn)網(wǎng)址","http://idcbgp.cn/"),'_blank','width=400,height=500,menubar=no,toolbar=no,scrollbars=yes,status=yes')//prompt的返回值是第二個字符串參數(shù),故默認(rèn)網(wǎng)址寫在第二個字符串參數(shù),以便用戶可以更改(比如改為www.baidu.com)
? }
?}
? </script>
</head>?
?<body>?
? <input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>