if(變量名!==null)是什么意思呢?不是應該confirm后直接window.open么?
<!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 url=confirm("是否打開網頁?");
? ? // 新窗口打開時彈出確認框,是否打開
? ? ? if(url==true)
? ? ? {var pp=prompt("http://www.xianlaiwan.cn/");
? ? // 通過輸入對話框,確定打開的網址,默認為 http://www.xianlaiwan.cn/
? ? ? ? ?if(pp!==null)
? ? ? ? ?{window.open('http://www.xianlaiwan.cn/','_blank','width=400px,height=500px,manubar=no,toolbar=no');}
? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ? ? ?}
? ? ? else{alert("好好難");}
? ?}?
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網站" onclick="openWindow()" />?
?</body>
</html>
2020-01-19
!== 就是不相等 null 就是空的意思
設置if( !==null) 就是為了取消也不會打開網站
2020-02-24
?function openWindow()
? ? {
? ? ?var url=confirm("是否打開網頁?");
? ???// 新窗口打開時彈出確認框,是否打開
? ? ?if(url==true){
? ? ????? var pp=prompt("請輸入要打開的網址",“http://www.xianlaiwan.cn”);
? ? ??????// 通過輸入對話框,確定打開的網址,默認為 http://www.xianlaiwan.cn/? ? ? ?????????????????????????? ? ? ???????????????????????window.open(pp,'_blank','width=400px,height=500px,manubar=no,toolbar=no');
? ? ??????//打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ? }
? ? ? else{alert("好好難");}
? ?}?