運(yùn)行效果怎么沒有默認(rèn)的打開慕課網(wǎng)頁
<!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 url=prompt("請(qǐng)輸入網(wǎng)址");
? ? }
? ? if(url=='http://idcbgp.cn/')
? ? {window.open('http://idcbgp.cn/','_blank','width=400,height=500,menubar=no,toolbar=no');}
? ? else
? ? {document.write(nothing);}
? }
? ? // 新窗口打開時(shí)彈出確認(rèn)框,是否打開
? ?
? ? // 通過輸入對(duì)話框,確定打開的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
? ??
? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ??
? ??
? </script>?
?</head>?
?<body>?
? <input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
2019-12-10
<script type="text/javascript">
// 新窗口打開時(shí)彈出確認(rèn)框,是否打開
function openWindow() {
var con = confirm("是否打開新窗口?");
// 通過輸入對(duì)話框,確定打開的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
if(con == true) {
var pro = prompt("輸入需要打開的網(wǎng)址:");
if(pro == "") {
//打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
window.open("http://idcbgp.cn", "_blank", "width=400,height=500,menubar=no,toolbar=no");
} else {
window.open(pro, "_blank", "width=400,height=500,menubar=no,toolbar=no");
}
} else {
alert("哈哈哈");
}
}
</script>
2019-12-10
我覺得你可能理解錯(cuò)意思了?你的代碼的意思是點(diǎn)擊確認(rèn)過后,判斷你輸入的網(wǎng)址是否是慕課網(wǎng),是就打開,不是就寫nothing。我理解的題目的意思是默認(rèn)打開慕課網(wǎng),是否打開新窗口點(diǎn)擊確認(rèn)過后,判斷輸入的網(wǎng)址,不是判斷是否是慕課網(wǎng)的網(wǎng)址,而是輸入的什么就跳轉(zhuǎn)什么,當(dāng)什么都沒有輸入的什么就打開慕課網(wǎng)的網(wǎng)址。不知道我理解的對(duì)不對(duì)。還有一點(diǎn)就是,你代碼寫法有誤,判斷輸入的網(wǎng)址應(yīng)該寫在message==true{}里面。而不是外面。
2019-11-28
經(jīng)過實(shí)測(cè),原因很簡(jiǎn)單,http后面的冒號(hào)是中文冒號(hào),改成英文冒號(hào)就可以了,如果幫到了你,歡迎采納哈!
2019-11-28
var url =prompt("請(qǐng)輸入網(wǎng)址","http://idcbgp.cn");