課程
/前端開發
/JavaScript
/JavaScript入門篇
http://www.xianlaiwan.cn/code/1642
2016-11-29
源自: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"> ?
? ? function openWindow(){
? ? ? ? // 新窗口打開時彈出確認框,是否打開
? ? ? ? var meg=confirm("確認打開新窗口嗎");
? ? ? ? if(meg==true){
? ? ? ? // 通過輸入對話框,確定打開的網址,默認為 http://www.xianlaiwan.cn/
? ? ? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ? ? ? ? ? window.open('http://www.xianlaiwan.cn',
? ? ? ? ? ? 'width=400px,height=500px,menubar=no,toolbar=no');
? ? ? ? }
? ? }
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網站" onclick="openWindow()" />?
?</body>
</html>
這是我寫的代碼 ?這個很簡單的 ?你寫的有點復雜了
慕粉4370907 提問者
混世小魔王ok 回復 慕粉4370907 提問者
慕粉4370907 提問者 回復 混世小魔王ok
? // 新窗口打開時彈出確認框,是否打開??
? var mysrt = confirm("是否打開網頁");
? ? ? ? ? ? if (mysrt == true) {
? ? ? ? ? ? ? ??? ? // 通過輸入對話框,確定打開的網址,默認為 http://www.xianlaiwan.cn/
????????????????? ?var my = prompt("請輸入網址", "http://www.xianlaiwan.cn/");
?
? ? ? ? ? ? ? ? ? ? if (my != null) {
? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ? ? ? ? ? ? ? ? ? ? ? window.open(my, 'http://www.xianlaiwan.cn', '_blank', 'width=400px,height=500px,menubar=no,toolbar=no')
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? else{
? ? ? ? ? ? ? ? ? ? ? ? ? ? alert("再見");
? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ? else {
? ? ? ? ? ? ? ? alert("再見!");
? ??
舉報
JavaScript做為一名Web工程師的必備技術,本教程讓您快速入門
2 回答為什么這段代碼運行后輸入新的網址,打開的還是慕課網的網址,問題出在哪?
4 回答為什么打不開慕課網站
5 回答請問我 這樣為什么當在最后是不能打開默認的慕課網
5 回答麻煩請問我的代碼為什么打開的不是慕課的網址
5 回答為什么我的代碼運行后沒有打開網址
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2016-11-29
上面的代碼試了沒有?
2016-11-29
<!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 meg=confirm("確認打開新窗口嗎");
? ? ? ? if(meg==true){
? ? ? ? // 通過輸入對話框,確定打開的網址,默認為 http://www.xianlaiwan.cn/
? ? ? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ? ? ? ? ? window.open('http://www.xianlaiwan.cn',
? ? ? ? ? ? 'width=400px,height=500px,menubar=no,toolbar=no');
? ? ? ? }
? ? }
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網站" onclick="openWindow()" />?
?</body>
</html>
這是我寫的代碼 ?這個很簡單的 ?你寫的有點復雜了
2016-11-29
<!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 mysrt = confirm("是否打開網頁");
? ? ? ? ? ? if (mysrt == true) {
? ? ? ? ? ? ? ??? ? // 通過輸入對話框,確定打開的網址,默認為 http://www.xianlaiwan.cn/
????????????????? ?var my = prompt("請輸入網址", "http://www.xianlaiwan.cn/");
?
? ? ? ? ? ? ? ? ? ? if (my != null) {
? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ? ? ? ? ? ? ? ? ? ? ? window.open(my, 'http://www.xianlaiwan.cn', '_blank', 'width=400px,height=500px,menubar=no,toolbar=no')
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? else{
? ? ? ? ? ? ? ? ? ? ? ? ? ? alert("再見");
? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ? else {
? ? ? ? ? ? ? ? alert("再見!");
? ? ? ? ? ? }
?
? ? ? ? }
? ??
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網站" onclick="openWindow()" />?
?</body>
</html>