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