窗口打不開
<!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)址嗎?);
? ? // 新窗口打開時彈出確認(rèn)框,是否打開
? ? if(open==ture)
? ? { var url=prompt(確定打開的網(wǎng)址http://idcbgp.cn/)
? ? ? ?
? ? // 通過輸入對話框,確定打開的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
? ? ?if(url!=null)
? ?{window.open('url' '_blank' 'width=400px,height=500px');} //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ? else
? ? {alert("打開失敗");}
? ? else
? ? {alert("打開失敗");}
? ? }
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
請問為什么彈出alert窗口之后,就沒有彈出輸入網(wǎng)址的窗口
2018-03-07
剛剛幫同學(xué)的代碼測試了一下,發(fā)現(xiàn)同學(xué)的代碼有些語法錯誤呀,
open=true,而不是ture哦。。
格式:prompt("str1","str2"); 還有 window.open();
最后就是alert();? 分號要用英文半角(程序的符號都要用英文半角吶)。
2018-03-07
var url=prompt("確定打開的網(wǎng)址?","http://idcbgp.cn/");