課程
/前端開發(fā)
/JavaScript
/JavaScript入門篇
想尋求幫助 2-7的正確標(biāo)準(zhǔn)答案
2018-11-14
源自:JavaScript入門篇 3-1
正在回答
這是修改后的代碼,代碼里也貼了注釋,就是if嵌套加上語法調(diào)用
? <script type="text/javascript">
? ? function openWindow(){
? ? ? ? var mymessage=confirm("是否繼續(xù)打開該窗口");
? ? ? ? if(mymessage==true)
? ? ? ? {
? ? ? ? ? ? window.close();? ? ? ??
? ? ? ? ? ? var wz=prompt("請輸入要訪問的網(wǎng)址,(需帶http://)默認(rèn)為http://idcbgp.cn/");
? ? ? ? ? ? if(wz!=null)? ? //若prompt的返回值不為null,即點確定,則繼續(xù),否則什么都不發(fā)生
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if(wz!='')
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? window.open(wz,'_blank','width=400,height=500,menubar=no,toolbar=no');
? ? ? ? ? ? ? ? ? ? //若文本框輸入地址,則跳轉(zhuǎn)到文本框輸入的地址
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? else
? ? ? ? ? ? ? ? ? ? window.open('http://idcbgp.cn','_blank','width=400,height=500,menubar=no,toolbar=no')
? ? ? ? ? ? ? ? ? ? //若文本框沒輸入地址,則跳轉(zhuǎn)到imooc
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? //若confirm的返回值為false,即不為true,則什么都不發(fā)生
? ? }
? ??
? ? // 新窗口打開時彈出確認(rèn)框,是否打開
? ? // 通過輸入對話框,確定打開的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? </script>?
最初的思念
給你參考下我剛剛做的把? ?
? ? ? ? if(mymessage==false)
? ? ? ? ? ? window.close();
? ? ? ? var wz=prompt("請輸入要訪問的網(wǎng)址,(需帶http://)默認(rèn)為http://idcbgp.cn/");
? ? ? ? if(wz!='')
? ? ? ? ? ? window.open(wz,'_blank','width=400,height=500,menubar=no,toolbar=no');
? ? ? ? else
? ? ? ? ? ? window.open('http://idcbgp.cn','_blank','width=400,height=500,menubar=no,toolbar=no')
我來個簡單的
<script type="text/javascript">??
? ? function openWindow()
{
????if(confirm("確認(rèn)打開嗎?"))
????{
????????var myweb;
????????if(myweb=prompt("確認(rèn)訪問網(wǎng)站:","http://idcbgp.cn"))
????????????open(myweb,'_blank','width=400,height=500,menubar=no,toolbar=no');
????????else
????????????alert("hhh");
????}
}
<!DOCTYPE html>
<html>
?<head>
? <title> new document </title> ?
? <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> ??
? <script type="text/javascript"> ?
? function openWindow(){
? ? ? var addw=confirm("是否點擊確認(rèn):")
? ? ? if(addw==true){
? ? ? ? ? var add=prompt('請輸入網(wǎng)址:','http://www.baidu.com');
? ? ? ? ? if(add!=null){
? ? ? ? ? ? ? window.open(add,"_blank","width=400,height=500,menubar=no,toolbar=no")
? ? ? ? ? }
? ? ? ? ? else{
? ? ? ? ? ? ? alert("新窗口未打開!");
? ? ? }
? ? ? else{
? ? ? ? ? alert("新窗口未打開!");
? }
?</head>?
?<body>?
?<input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
<!DOCTYPE html><html><head>??? <meta charset="UTF-8">??? <meta name="viewport" content="width=device-width, initial-scale=1.0">??? <meta http-equiv="X-UA-Compatible" content="ie=edge">??? <title>Document</title>??? <script type="text/javascript">? ??? ??????? function openWindow(){??????? ??????? // 新窗口打開時彈出確認(rèn)框,是否打開??? ??????? var fwin = confirm("是否要打開新的窗口");??????? if(fwin==true){?????????? var swin = prompt('請輸入目標(biāo)窗口地址:','');??????? ??????????? if(swin!=null&&swin!='')??????????? {??????????? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。?????????? ??????????? window.open(swin,'_blank','width=400','height=500','menubar=no','toolbar=no','status=no');????????????? ??????????? }??????????? else??????????? {??????????? // 通過輸入對話框,確定打開的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/??????????? window.open('http://idcbgp.cn','_blank','width=400','height=500','menubar=no','toolbar=no', 'status=no');?????????? ??????????? }??????? }???????? else???????? {???????????? fwin.close();???????????? //寫不寫都一樣,默認(rèn)都會關(guān)閉當(dāng)前窗口???????? }??????????? ??????? }????? </script> </head><body>??????? <input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" /> ??? </body></html>
? <title> new document </title>??
? <meta http-equiv="Content-Type" content="text/html; charset=gbk"/>? ?
? <script type="text/javascript">??
? ? ? ? var cc=confirm("是否打開?")
? ? ? ? if(cc==true)
? ? ? ? ? ? var ss=prompt("輸入打開的網(wǎng)址","http://idcbgp.cn/")
? ? ? ? ? ? if(ss!=null)
? ? ? ? ? ? window.open(ss,"_blank","width=400,height=500,menubar=no,toolbar=no");
? ? ? ? ? ? else{
? ? ? ? ? ? ? ? alert("你點擊了取消");
? ? ? ? ? ? alert("你點擊了取消");
? <input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
? <meta http-equiv="Content-Type" content="text/html; charset=gbk"/> ??
? ? ? ? if(confirm("確認(rèn)彈出窗口嗎?")){
? ? ? ? ? ? var url = prompt("請輸入一個網(wǎng)址","http://idcbgp.cn/");?
window.open(url,"_blank","width=400,height=500,menubar=no,toolbar");
function openWindow(){
? ? var open = confirm("確定打開對話框");
? ? if(open==true)
? ? {
? ? ? ? var url = prompt("2","http://idcbgp.cn");
? ? ? ? if(url!=null)
? ? ? ? ? ? window.open(url,'_blank','width=400,height=500,toolbar=no,menubar=no');
? ? ? ? }else
? ? ? ? ? ? alert("內(nèi)層結(jié)束");
? ? }else
? ? ? ? alert("外層結(jié)束");
方式一:利用confirm消息點擊對話框??
??<script type="text/javascript"> ?
?function openWindow(){ ??
?// 新窗口打開時彈出確認(rèn)框,是否打開
???var message=confirm("是否要打開慕課網(wǎng)?")
???if(message==true)
?//打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
window.open('http://idcbgp.cn/','width=400,height=500,menubar=no,toolbar=no') ??
?}
//網(wǎng)頁彈出警告提示用戶
?else
????????alert("您選擇取消是打不開慕課網(wǎng)的哦!")
?????</script>
?
方式二:利用prompt消息輸入對話框
<script type="text/javascript"> ?
// 通過輸入對話框,確定打開的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
var message=prompt("是否要打開慕課網(wǎng)?")
//輸入確定進(jìn)行下一步
if(message=="確定")
?confirm("即將進(jìn)入慕課網(wǎng)!點擊確定繼續(xù)!")
//打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。 ????window.open('http://idcbgp.cn/','width=400,height=500,menubar=no,toolbar=no') ??
???}
//輸入非確定則彈出提示框
else {
alert("您選擇取消進(jìn)入慕課網(wǎng)!")
</script>?
? ? ? var message = confirm("是否打開慕課網(wǎng)?");
? ? ? if(message = true){
? ? ? ? ? window.open('http://idcbgp.cn','_blank','width=400,height=500,menubar=no,toolbar=no');
? ? ? </script>?
舉報
JavaScript做為一名Web工程師的必備技術(shù),本教程讓您快速入門
2 回答標(biāo)準(zhǔn)答案!
1 回答標(biāo)準(zhǔn)答案!
3 回答正確的答案
7 回答求2-7編程練習(xí)答案
4 回答答案正確率
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)微信公眾號
2019-04-01
這是修改后的代碼,代碼里也貼了注釋,就是if嵌套加上語法調(diào)用
? <script type="text/javascript">
? ? function openWindow(){
? ? ? ? var mymessage=confirm("是否繼續(xù)打開該窗口");
? ? ? ? if(mymessage==true)
? ? ? ? {
? ? ? ? ? ? window.close();? ? ? ??
? ? ? ? ? ? var wz=prompt("請輸入要訪問的網(wǎng)址,(需帶http://)默認(rèn)為http://idcbgp.cn/");
? ? ? ? ? ? if(wz!=null)? ? //若prompt的返回值不為null,即點確定,則繼續(xù),否則什么都不發(fā)生
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if(wz!='')
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? window.open(wz,'_blank','width=400,height=500,menubar=no,toolbar=no');
? ? ? ? ? ? ? ? ? ? //若文本框輸入地址,則跳轉(zhuǎn)到文本框輸入的地址
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? else
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? window.open('http://idcbgp.cn','_blank','width=400,height=500,menubar=no,toolbar=no')
? ? ? ? ? ? ? ? ? ? //若文本框沒輸入地址,則跳轉(zhuǎn)到imooc
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? //若confirm的返回值為false,即不為true,則什么都不發(fā)生
? ? }
? ??
? ? // 新窗口打開時彈出確認(rèn)框,是否打開
? ? // 通過輸入對話框,確定打開的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ??
? ??
? </script>?
2019-04-01
給你參考下我剛剛做的把? ?
? <script type="text/javascript">
? ? function openWindow(){
? ? ? ? var mymessage=confirm("是否繼續(xù)打開該窗口");
? ? ? ? if(mymessage==false)
? ? ? ? {
? ? ? ? ? ? window.close();
? ? ? ? }
? ? ? ? var wz=prompt("請輸入要訪問的網(wǎng)址,(需帶http://)默認(rèn)為http://idcbgp.cn/");
? ? ? ? if(wz!='')
? ? ? ? {
? ? ? ? ? ? window.open(wz,'_blank','width=400,height=500,menubar=no,toolbar=no');
? ? ? ? }
? ? ? ? else
? ? ? ? {
? ? ? ? ? ? window.open('http://idcbgp.cn','_blank','width=400,height=500,menubar=no,toolbar=no')
? ? ? ? }
? ? }
? ??
? ? // 新窗口打開時彈出確認(rèn)框,是否打開
? ? // 通過輸入對話框,確定打開的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ??
? ??
? </script>?
2019-03-29
我來個簡單的
<script type="text/javascript">??
? ? function openWindow()
{
????if(confirm("確認(rèn)打開嗎?"))
????{
????????var myweb;
????????if(myweb=prompt("確認(rèn)訪問網(wǎng)站:","http://idcbgp.cn"))
????????????open(myweb,'_blank','width=400,height=500,menubar=no,toolbar=no');
????????else
????????????alert("hhh");
????}
}
? </script>?
2019-03-02
<!DOCTYPE html>
<html>
?<head>
? <title> new document </title> ?
? <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> ??
? <script type="text/javascript"> ?
? function openWindow(){
? ? ? var addw=confirm("是否點擊確認(rèn):")
? ? ? if(addw==true){
? ? ? ? ? var add=prompt('請輸入網(wǎng)址:','http://www.baidu.com');
? ? ? ? ? if(add!=null){
? ? ? ? ? ? ? window.open(add,"_blank","width=400,height=500,menubar=no,toolbar=no")
? ? ? ? ? }
? ? ? ? ? else{
? ? ? ? ? ? ? alert("新窗口未打開!");
? ? ? ? ? }
? ? ? }
? ? ? else{
? ? ? ? ? alert("新窗口未打開!");
? ? ? }
? }
? ??
? ? // 新窗口打開時彈出確認(rèn)框,是否打開
? ? // 通過輸入對話框,確定打開的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ??
? ??
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
2019-01-21
<!DOCTYPE html>
<html>
<head>
??? <meta charset="UTF-8">
??? <meta name="viewport" content="width=device-width, initial-scale=1.0">
??? <meta http-equiv="X-UA-Compatible" content="ie=edge">
??? <title>Document</title>??? <script type="text/javascript">?
???
??????? function openWindow(){
???????
??????? // 新窗口打開時彈出確認(rèn)框,是否打開???
??????? var fwin = confirm("是否要打開新的窗口");
??????? if(fwin==true){
?????????? var swin = prompt('請輸入目標(biāo)窗口地址:','');
???????
??????????? if(swin!=null&&swin!='')
??????????? {
??????????? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
??????????
??????????? window.open(swin,'_blank','width=400','height=500','menubar=no','toolbar=no','status=no');
?????????????
??????????? }
??????????? else
??????????? {
??????????? // 通過輸入對話框,確定打開的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
??????????? window.open('http://idcbgp.cn','_blank','width=400','height=500','menubar=no','toolbar=no', 'status=no');
??????????
??????????? }
??????? }
???????? else
???????? {
???????????? fwin.close();
???????????? //寫不寫都一樣,默認(rèn)都會關(guān)閉當(dāng)前窗口
???????? }
???????????
??????? }
????? </script> </head>
<body>??????? <input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />
???
</body>
</html>
2018-12-24
<!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 cc=confirm("是否打開?")
? ? ? ? if(cc==true)
? ? ? ? {
? ? ? ? ? ? var ss=prompt("輸入打開的網(wǎng)址","http://idcbgp.cn/")
? ? ? ? ? ? if(ss!=null)
? ? ? ? ? ? {
? ? ? ? ? ? window.open(ss,"_blank","width=400,height=500,menubar=no,toolbar=no");
? ? ? ? ? ? }
? ? ? ? ? ? else{
? ? ? ? ? ? ? ? alert("你點擊了取消");
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? else
? ? ? ? {
? ? ? ? ? ? alert("你點擊了取消");
? ? ? ? }
? ? }
? ??
? </script>?
?</head>?
?<body>?
? <input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
2018-12-07
<!DOCTYPE html>
<html>
?<head>
? <title> new document </title> ?
? <meta http-equiv="Content-Type" content="text/html; charset=gbk"/> ??
? <script type="text/javascript"> ?
? ? function openWindow(){
? ? ? ? if(confirm("確認(rèn)彈出窗口嗎?")){
? ? ? ? ? ? var url = prompt("請輸入一個網(wǎng)址","http://idcbgp.cn/");?
window.open(url,"_blank","width=400,height=500,menubar=no,toolbar");
? ? ? ? }
? ? }
? ? // 新窗口打開時彈出確認(rèn)框,是否打開
? ? // 通過輸入對話框,確定打開的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ??
? ??
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
2018-11-20
<!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("確定打開對話框");
? ? if(open==true)
? ? {
? ? ? ? var url = prompt("2","http://idcbgp.cn");
? ? ? ? if(url!=null)
? ? ? ? {
? ? ? ? ? ? window.open(url,'_blank','width=400,height=500,toolbar=no,menubar=no');
? ? ? ? }else
? ? ? ? {
? ? ? ? ? ? alert("內(nèi)層結(jié)束");
? ? ? ? }
? ? }else
? ? {
? ? ? ? alert("外層結(jié)束");
? ? }
}
? ??
? </script>?
?</head>?
?<body>?
? <input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
2018-11-19
方式一:利用confirm消息點擊對話框??
??<script type="text/javascript"> ?
?function openWindow(){ ??
?// 新窗口打開時彈出確認(rèn)框,是否打開
???var message=confirm("是否要打開慕課網(wǎng)?")
???if(message==true)
{
?//打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
window.open('http://idcbgp.cn/','width=400,height=500,menubar=no,toolbar=no') ??
?}
//網(wǎng)頁彈出警告提示用戶
?else
????{
????????alert("您選擇取消是打不開慕課網(wǎng)的哦!")
????}
}
?????</script>
?
方式二:利用prompt消息輸入對話框
<script type="text/javascript"> ?
function openWindow(){
// 通過輸入對話框,確定打開的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
var message=prompt("是否要打開慕課網(wǎng)?")
//輸入確定進(jìn)行下一步
if(message=="確定")
{
?// 新窗口打開時彈出確認(rèn)框,是否打開
?confirm("即將進(jìn)入慕課網(wǎng)!點擊確定繼續(xù)!")
//打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。 ????window.open('http://idcbgp.cn/','width=400,height=500,menubar=no,toolbar=no') ??
???}
//輸入非確定則彈出提示框
else {
alert("您選擇取消進(jìn)入慕課網(wǎng)!")
????}
}
</script>?
2018-11-14
<!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("是否打開慕課網(wǎng)?");
? ? ? if(message = true){
? ? ? ? ? window.open('http://idcbgp.cn','_blank','width=400,height=500,menubar=no,toolbar=no');
? ? ? }
? }
? ??
? ? // 新窗口打開時彈出確認(rèn)框,是否打開
? ? // 通過輸入對話框,確定打開的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ? ? </script>?
?</head>?
?<body>?
? <input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>