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