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