<!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?mas=confirm("您好,是否打開新窗口?")//?新窗口打開時(shí)彈出確認(rèn)框,是否打開
????if(mas==ture)//?通過輸入對話框,確定打開的網(wǎng)址,默認(rèn)為?http://idcbgp.cn/
????{?window.open("http://idcbgp.cn/","_blank","width:400,height:600,menubar:no,toolbar:no");?}
????else
????{?document.wrirte("I?love?javascript");?}
????//打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
????}
????
??</script>?
?</head>?
?<body>?
??<input?type="button"?value="新窗口打開網(wǎng)站"?onclick="openWindow()"?/>?
?</body>
</html>
2016-12-20
1、if(mas==ture)中的“ture”改為true.
2、document.wrirte("I?love?javascript");中的“wrirte”改為write。
2016-12-18
confirm前面少一個(gè)空格- -
2016-12-17
看不出來
2016-12-17
把if語句中的條件換成 mas,即可。
confirm返回的就是boolean值,可以直接做判斷。