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