課程
/前端開發(fā)
/JavaScript
/JavaScript入門篇
下面的這個
if(mymsg2!=null){
....
}
這個判斷條件怎么完善?如果輸入框輸入的不是正確的網(wǎng)址肯定是打不開的 但是肯定不是null,所以怎么完善一下?哪位兄臺能指點(diǎn)一下?
2017-01-13
源自:JavaScript入門篇 2-7
正在回答
<!DOCTYPE html><html><head> ? ?<title> new document </title> ? ?<meta http-equiv="Content-Type" content="text/html; charset=gbk"/> ? ?<script type="text/javascript"> ? ? ? ?// 新窗口打開時彈出確認(rèn)框,是否打開 ? ? ? ?function openWindow(){ ? ? ? ? ? ?var mymsg= confirm("是否打開新網(wǎng)頁?"); ? ? ? ? ? ?if(mymsg==true){ ? ? ? ? ? ? ? ?var mymsg2 = prompt("請輸出一個網(wǎng)址","http://idcbgp.cn/"); ? ? ? ? ? ? ? ?var wz="http://idcbgp.cn/"; ? ? ? ? ? ? ? ?if (mymsg2==wz){ ? ? ? ? ? ? ? ? ? ?window.open(mymsg2,"_blank","width:400px,height:500px") ? ? ? ? ? ? ? ?} ? ? ? ? ? ? ? ?else{ ? ? ? ? ? ? ? ? ? var a=confirm('這個網(wǎng)頁不是慕課網(wǎng),你確定要打開么?') ? ? ? ? ? ? ? ? ? ?if (a==true){ ? ? ? ? ? ? ? ? ? ? ? ?window.open(mymsg2,"_blank","width:400px,height:500px") ? ? ? ? ? ? ? ? ? ?} ? ? ? ? ? ? ? ?} ? ? ? ? ? ?} ? ? ? ? ? ?else{ ? ? ? ? ? ? ? ?alert("歡迎下次打開"); ? ? ? ? ? ?} ? ? ? ?} ? ? ? ?// 通過輸入對話框,確定打開的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/ ? ? ? ?//打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。 ? ?</script></head><body><input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" /></body></html>
<!DOCTYPE html><html><head> ? ?<title> new document </title> ? ?<meta http-equiv="Content-Type" content="text/html; charset=gbk"/> ? ?<script type="text/javascript"> ? ? ? ?// 新窗口打開時彈出確認(rèn)框,是否打開 ? ? ? ?function openWindow(){ ? ? ? ? ? ?var mymsg= confirm("是否打開新網(wǎng)頁?"); ? ? ? ? ? ?if(mymsg==true){ ? ? ? ? ? ? ? ?var mymsg2 = prompt("請輸出一個網(wǎng)址","http://idcbgp.cn/"); ? ? ? ? ? ? ? ?var wz="http://idcbgp.cn/"; ? ? ? ? ? ? ? ?if (mymsg2==wz){ ? ? ? ? ? ? ? ? ? ?window.open(mymsg2,"_blank","width:400px,height:500px") ? ? ? ? ? ? ? ?} ? ? ? ? ? ? ? ?else{ ? ? ? ? ? ? ? ? ? ?alert ("那好吧,不打開就不打開!"); ? ? ? ? ? ? ? ?} ? ? ? ? ? ?} ? ? ? ? ? ?else{ ? ? ? ? ? ? ? ?alert("歡迎下次打開"); ? ? ? ? ? ?} ? ? ? ?} ? ? ? ?// 通過輸入對話框,確定打開的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/ ? ? ? ?//打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。 ? ?</script></head><body><input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" /></body></html>
李大仁阿 提問者
勢ice 回復(fù) 李大仁阿 提問者
李大仁阿 提問者 回復(fù) 勢ice
舉報
JavaScript做為一名Web工程師的必備技術(shù),本教程讓您快速入門
1 回答這個代碼完整是怎么樣的?
5 回答這個代碼怎么寫?
3 回答這個代碼怎么寫
3 回答這個代碼怎么錯了
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)微信公眾號
2017-01-13
<!DOCTYPE html>
<html>
<head>
? ?<title> new document </title>
? ?<meta http-equiv="Content-Type" content="text/html; charset=gbk"/>
? ?<script type="text/javascript">
? ? ? ?// 新窗口打開時彈出確認(rèn)框,是否打開
? ? ? ?function openWindow(){
? ? ? ? ? ?var mymsg= confirm("是否打開新網(wǎng)頁?");
? ? ? ? ? ?if(mymsg==true){
? ? ? ? ? ? ? ?var mymsg2 = prompt("請輸出一個網(wǎng)址","http://idcbgp.cn/");
? ? ? ? ? ? ? ?var wz="http://idcbgp.cn/";
? ? ? ? ? ? ? ?if (mymsg2==wz){
? ? ? ? ? ? ? ? ? ?window.open(mymsg2,"_blank","width:400px,height:500px")
? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ?else{
? ? ? ? ? ? ? ? ? var a=confirm('這個網(wǎng)頁不是慕課網(wǎng),你確定要打開么?')
? ? ? ? ? ? ? ? ? ?if (a==true){
? ? ? ? ? ? ? ? ? ? ? ?window.open(mymsg2,"_blank","width:400px,height:500px")
? ? ? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ?}
? ? ? ? ? ?}
? ? ? ? ? ?else{
? ? ? ? ? ? ? ?alert("歡迎下次打開");
? ? ? ? ? ?}
? ? ? ?}
? ? ? ?// 通過輸入對話框,確定打開的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
? ? ? ?//打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ?</script>
</head>
<body>
<input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />
</body>
</html>
2017-01-13
<!DOCTYPE html>
<html>
<head>
? ?<title> new document </title>
? ?<meta http-equiv="Content-Type" content="text/html; charset=gbk"/>
? ?<script type="text/javascript">
? ? ? ?// 新窗口打開時彈出確認(rèn)框,是否打開
? ? ? ?function openWindow(){
? ? ? ? ? ?var mymsg= confirm("是否打開新網(wǎng)頁?");
? ? ? ? ? ?if(mymsg==true){
? ? ? ? ? ? ? ?var mymsg2 = prompt("請輸出一個網(wǎng)址","http://idcbgp.cn/");
? ? ? ? ? ? ? ?var wz="http://idcbgp.cn/";
? ? ? ? ? ? ? ?if (mymsg2==wz){
? ? ? ? ? ? ? ? ? ?window.open(mymsg2,"_blank","width:400px,height:500px")
? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ?else{
? ? ? ? ? ? ? ? ? ?alert ("那好吧,不打開就不打開!");
? ? ? ? ? ? ? ?}
? ? ? ? ? ?}
? ? ? ? ? ?else{
? ? ? ? ? ? ? ?alert("歡迎下次打開");
? ? ? ? ? ?}
? ? ? ?}
? ? ? ?// 通過輸入對話框,確定打開的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
? ? ? ?//打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ?</script>
</head>
<body>
<input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />
</body>
</html>