課程
/前端開發(fā)
/JavaScript
/JavaScript入門篇
幫忙看一下是怎么回事
2016-05-25
源自:JavaScript入門篇 2-7
正在回答
把那個?if (website!="")改為if(website!=null)
中國小小唐
慕粉3398407 提問者
<!DOCTYPE html><html>?<head>?<meta charset="utf-8">? <title> new document </title> ?? <meta http-equiv="Content-Type" content="text/html; charset=gbk"/>? ?? <script type="text/javascript"> ??? ???? function openWindow()??? {?? ??? ?var x = confirm("確認(rèn)打開新網(wǎng)頁?")?? ??? ?if (x == true)?? ??? ?{?? ??? ??? ?var website = prompt("請輸入您要打開的網(wǎng)址","http://idcbgp.cn/");?? ??? ??? ?if (website!="")?? ??? ??? ?{?? ??? ??? ??? ??? ??? ??? ?window.open(website,'_blank','width=300,height=200,menubar=no,toolbar=no')?? ??? ??? ?}?? ??? ??? ?else ?? ??? ??? ?{?? ??? ??? ??? ?alert("網(wǎng)址不能為空!")?? ??? ??? ?}?? ??? ?}?? ??? ?else?? ??? ?{?? ??? ??? ?alert("您點(diǎn)擊了取消")?? ??? ?}???? }??? // 通過輸入對話框,確定打開的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/??? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。?? ??? ?? </script> ?</head> ?<body> ?? ?? <input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" /> ?</body></html>
舉報
JavaScript做為一名Web工程師的必備技術(shù),本教程讓您快速入門
2 回答打開新網(wǎng)址,點(diǎn)擊取消,不會出現(xiàn)空白網(wǎng)頁
1 回答為什么網(wǎng)址輸入為空的時候還是能打開一個空白頁面,而不是輸出網(wǎng)址為空
3 回答點(diǎn)取消時候,會打開空的新網(wǎng)頁,怎么改呢?
3 回答點(diǎn)擊取消時重新輸入網(wǎng)頁地址打不開
1 回答為什么不輸入網(wǎng)址,還能打開一個空白頁?
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2016-05-25
把那個?if (website!="")改為if(website!=null)
2016-05-25
<!DOCTYPE html>
<html>
?<head>
?<meta charset="utf-8">
? <title> new document </title> ?
? <meta http-equiv="Content-Type" content="text/html; charset=gbk"/>? ?
? <script type="text/javascript"> ?
?? ?
??? function openWindow()
??? {
?? ??? ?var x = confirm("確認(rèn)打開新網(wǎng)頁?")
?? ??? ?if (x == true)
?? ??? ?{
?? ??? ??? ?var website = prompt("請輸入您要打開的網(wǎng)址","http://idcbgp.cn/");
?? ??? ??? ?if (website!="")
?? ??? ??? ?{
?? ??? ??? ?
?? ??? ??? ??? ?window.open(website,'_blank','width=300,height=200,menubar=no,toolbar=no')
?? ??? ??? ?}
?? ??? ??? ?else
?? ??? ??? ?{
?? ??? ??? ??? ?alert("網(wǎng)址不能為空!")
?? ??? ??? ?}
?? ??? ?}
?? ??? ?else
?? ??? ?{
?? ??? ??? ?alert("您點(diǎn)擊了取消")
?? ??? ?}
???? }
??? // 通過輸入對話框,確定打開的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
??? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
?? ?
?? ?
? </script>
?</head>
?<body>
?? ?? <input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />
?</body>
</html>