打不開新網(wǎng)址
輸入網(wǎng)址后點擊確認(rè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 openWindow(){
? ? ? ? var message=confirm("確定打開新網(wǎng)頁嗎?");
? ? ? ? if (message==true){
? ? ? ? ? ? var url0=prompt("請輸入網(wǎng)址","http://idcbgp.cn");
? ? ? ? ? ? if(url0!=""){
? ? ? ? ? ? ? ? window.open("url0","_blank","height=500,width=400,menubar=no,toolbar=no");}
? ? ? ? ? ? else(){
? ? ? ? ? ? ? alert("再見!");}}
? ? ? ? else(){
? ? ? ? ? ? alert("再見!");}
? ? }
? ??
? </script>?
?</head>?
?<body>?
? <input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
2020-07-01
1,var url0=prompt("請輸入網(wǎng)址","http://idcbgp.cn"); ?
這句里面冒號錯寫成了中文冒號,
2,window.open里面的url0不應(yīng)該加引號。因為url0是變量,而不是字符串
3,下面的else(){? }出錯了。沒有括號。正確的應(yīng)該是else{? }
2020-07-01
明白了?非常感謝大家!
2020-07-01
為什么呢?url0?這里就是http://blablabla.com?它本身雖然是字符串?但是不是需要window.open("網(wǎng)址")這樣的形式嘛?然后光改了url0還不行?我把else刪了才可以?我的else寫的不對嗎?感謝您!
2020-07-01
1) url0 不能加 雙/單引號
2) 關(guān)閉 瀏覽器的攔截窗口彈出設(shè)置