課程
/前端開發
/JavaScript
/JavaScript入門篇
我按要求的寫了,可是點擊按后并不是彈出窗口而是打開新的標簽頁,看了其他人代碼,發現也一樣,究竟是我瀏覽器的問題,還是代碼有問題啊
2017-09-11
源自:JavaScript入門篇 2-5
正在回答
代碼沒問題,我復制了你的代碼在谷歌,火狐,IE上運行都是打開新的窗口,我猜是你瀏覽器問題
兼容性問題你用chrome試下就知道了
你的窗口沒寫、這是我剛學完自己寫的
<!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("是否打開新窗口?");
? ? ? ? if(message==true)
? ? ? ??
? ? ? ? var myurl=prompt("請輸入網址");
? ? ? ? if(myurl==null)
? ? ? ? {
? ? ? ? ? ? window.open('http://www.xianlaiwan.cn','_black','width=400,hight=500,menubar=no,toolbar=no')
? ? ? ? }
? ? ? ? else
? ? ? ? ? ? window.open('myurl','_black','width=400,hight=500,menubar=no,toolbar=no')
? ? }
? ? // 新窗口打開時彈出確認框,是否打開
? ? // 通過輸入對話框,確定打開的網址,默認為 http://www.xianlaiwan.cn/
? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ??
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網站" onclick="openWindow()" />?
?</body>
</html>
黑炎藍焰 提問者
舉報
JavaScript做為一名Web工程師的必備技術,本教程讓您快速入門
4 回答彈不出窗口怎么辦
1 回答彈不出窗口
4 回答彈不出窗口
4 回答沒有彈出窗口
3 回答為什么不彈出窗口?
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2017-09-11
代碼沒問題,我復制了你的代碼在谷歌,火狐,IE上運行都是打開新的窗口,我猜是你瀏覽器問題
2017-09-11
兼容性問題你用chrome試下就知道了
2017-09-11
你的窗口沒寫、這是我剛學完自己寫的
<!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("是否打開新窗口?");
? ? ? ? if(message==true)
? ? ? ??
? ? ? ? var myurl=prompt("請輸入網址");
? ? ? ? if(myurl==null)
? ? ? ? {
? ? ? ? ? ? window.open('http://www.xianlaiwan.cn','_black','width=400,hight=500,menubar=no,toolbar=no')
? ? ? ? }
? ? ? ? else
? ? ? ? {
? ? ? ? ? ? window.open('myurl','_black','width=400,hight=500,menubar=no,toolbar=no')
? ? ? ? }
? ? }
? ? // 新窗口打開時彈出確認框,是否打開
? ? // 通過輸入對話框,確定打開的網址,默認為 http://www.xianlaiwan.cn/
? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ??
? ??
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網站" onclick="openWindow()" />?
?</body>
</html>