課程
/前端開(kāi)發(fā)
/JavaScript
/JavaScript入門篇
第12行的mes==""為什么替換成mes==null運(yùn)行結(jié)果就不對(duì)了
2020-04-08
源自:JavaScript入門篇 2-7
正在回答
因?yàn)槟阍谳斎肟蚴裁炊疾惠斎氲臅r(shí)候發(fā)送的字符串是“”而不是null,null代表不存在,但實(shí)際上你在輸入框里是有東西的,“”!= null
<!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("是否打開(kāi)網(wǎng)頁(yè)?");
? ? ? ? if(open==true){
? ? ? ? ? ? var mes=prompt("請(qǐng)輸入要訪問(wèn)的網(wǎng)址:");
? ? ? ? ? ? if(mes=="")
? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? window.open('http://idcbgp.cn/','_blank','width=400,height=500,menubar=no,toolbar=no');
? ? ? ? ? ? }
? ? ? ? ? ?else
? ? ? ? ? ?{
? ? ? ? ? ? ? ?window.open('https://www.baidu.com/','_blank','width=400,height=500,menubar=no,toolbar=no');
? ? ? ? ? ?}
? ? ? ? }
? ? }
? </script>?
?</head>?
?<body>?
? <input type="button" value="新窗口打開(kāi)網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
舉報(bào)
JavaScript做為一名Web工程師的必備技術(shù),本教程讓您快速入門
5 回答代碼寫成這樣,為什么運(yùn)行結(jié)果不對(duì)
2 回答運(yùn)行結(jié)果不對(duì)
5 回答為什么第六行加了script就不顯示結(jié)果了呢
3 回答為什么運(yùn)行不出結(jié)果
4 回答為什么第一個(gè)能運(yùn)行第二個(gè)運(yùn)行不了
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)
2020-04-10
因?yàn)槟阍谳斎肟蚴裁炊疾惠斎氲臅r(shí)候發(fā)送的字符串是“”而不是null,null代表不存在,但實(shí)際上你在輸入框里是有東西的,“”!= null
2020-04-08
<!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("是否打開(kāi)網(wǎng)頁(yè)?");
? ? ? ? if(open==true){
? ? ? ? ? ? var mes=prompt("請(qǐng)輸入要訪問(wèn)的網(wǎng)址:");
? ? ? ? ? ? if(mes=="")
? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? window.open('http://idcbgp.cn/','_blank','width=400,height=500,menubar=no,toolbar=no');
? ? ? ? ? ? }
? ? ? ? ? ?else
? ? ? ? ? ?{
? ? ? ? ? ? ? ?window.open('https://www.baidu.com/','_blank','width=400,height=500,menubar=no,toolbar=no');
? ? ? ? ? ?}
? ? ? ? }
? ? }
? </script>?
?</head>?
?<body>?
? <input type="button" value="新窗口打開(kāi)網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>