為啥點擊沒反應啊
<!DOCTYPE html>
<html>
?<head>
? <title> new document </title> ?
? <meta http-equiv="Content-Type" content="text/html; charset=gbk"/> ??
? <script type="text/javascript"> ?
?function text(){
? ? var open=confirm(“是否重新打開網址”)
? ? ?if(open=true)
? ? ?{var wangzhi=prompt("通過輸入對話框,確定打開的網址“默認為 http://www.xianlaiwan.cn/") }
? ? ?if(wangzhi=null)
? ? ?{window.open(wangzhi,'_blank','width=400px','height=500px','menubar=no','toolbar=no')}
? ? ?else
? ? ?{alert("再見")}
? ? ?else
? ? ?{alert("再見")}// 新窗口打開時彈出確認框,是否打開
? ? }text()
? ? ??
?
? ? // 通過輸入對話框,確定打開的網址,默認為 http://www.xianlaiwan.cn/
? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ??
? ??
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網站" onclick="openWindow()" />?
?</body>
</html>
2018-05-31
1、函數名必須為openWindow(),這樣點擊的時候才會觸發
2、if判斷里面,應該用==判斷
2018-05-31
?function openWindow(){
? ? var open=confirm("是否重新打開網址");
? ? ?if(open==true){
? ? ? ? ?var wangzhi=prompt("通過輸入對話框,確定打開的網址“默認為 http://www.xianlaiwan.cn/") ;
? ? ? ? if(wangzhi==null){
? ? ? ? ? ? window.open("http://www.xianlaiwan.cn/",'_blank','width=400px,height=500px,menubar=no,toolbar=no')}
? ? ? ? else{alert("再見")}
? ? ?}
? ? ?else{alert("再見")}// 新窗口打開時彈出確認框,是否打開
? ? }
你的prompt是要點擊取消才會返回null;注意“”的英文狀態,還有if大括號的范圍
2018-05-31
<!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 open=confirm(“是否重新打開網址”);
? ? ?if(open==true)
? ? ?{
? ? ? ? ?var wangzhi=prompt("通過輸入對話框,確定打開的網址“默認為 http://www.xianlaiwan.cn/")?
? ? ? ? ?
? ? ?};
? ? ?if(wangzhi==null)
? ? ?{
? ? ? ? ?window.open('http://www.xianlaiwan.cn/','_blank','width=400px','height=500px','menubar=no','toolbar=no')
? ? ? ? ?
? ? ?};
? ? ?else
? ? ?{
? ? ? ? ?alert("再見")
? ? ? ? ?
? ? ?};
? ? ?else
? ? ?{
? ? ? ? ?alert("再見")
? ? ? ? ?
? ? ?};// 新窗口打開時彈出確認框,是否打開
? ? }openWindow()
? ? ??
?
? ? // 通過輸入對話框,確定打開的網址,默認為 http://www.xianlaiwan.cn/
? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ??
? ??
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網站" onclick="openWindow()" />?
?</body>
</html>
還是點擊沒反應啊··是這個練習的編輯器有問題嗎?
2018-05-31
if(open==true){
//注意 是==不是=
}