亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

學習JAVAscript 遇到的問題 2-7編程練習

學習JAVAscript 遇到的問題 2-7編程練習

杰猛人 2015-04-18 17:46:18
<!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 chuang=confirm("您要打開一個新的窗口嗎?");? ? ? ? // 新窗口打開時彈出確認框,是否打開? ? ? ? var website;? ? ? ??? ? ? ? if(chuang==true)? ? ? ? { website=prompt("請確認要訪問的網址并確認"?? ? ? ? ?,"http://www.xianlaiwan.cn" );? ? ??? ? ? ? }? ? ? ? ?else{}? ? ? ? if(website!=null)? ? ? ? {? ? ? ? window.open("website","_blank","width=100? ? ? ? ,height=500,menubar=no,toolbar=no")? ? ? ? }? ??? ? ? ?? ??? } ? ?? </script>??</head>??<body>? ?<input type="button" value="新窗口打開網站" onclick="openWindow()" />??</body></html>
查看完整描述

1 回答

?
Perona

TA貢獻355條經驗 獲得超403個贊

??window.open("website","_blank","width=100,height=500,menubar=no,toolbar=no")

這里變量名是不需要加引號的。

代碼中if語言沒有正確嵌套。

修改后的代碼

<!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?chuang?=?confirm("您要打開一個新的窗口嗎?");
????????????//?新窗口打開時彈出確認框,是否打開
????????????var?website;
????????????if?(chuang?==?true)?{
????????????????website?=?prompt("請確認要訪問的網址并確認",?"http://www.xianlaiwan.cn");
????????????????if?(website?!=?null)?{
????????????????????window.open(website,?"_blank",?"width=100,height=500,menubar=no,toolbar=no")
????????????????}
????????????}else?{
????????????}
????????}
????</script>
</head>
<body>
<input?type="button"?value="新窗口打開網站"?onclick="openWindow()"/>
</body>
</html>


查看完整回答
反對 回復 2016-01-15
  • 1 回答
  • 0 關注
  • 1529 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號