為什么這個不行啊
為什么這不可以?
<html>
?<head>
? <title> new document </title>?
? <meta http-equiv="Content-Type" content="text/html; charset=gbk"/>??
? <script type="text/javascript">?
???
?? function openWindow(){
?????? var xinxi=prompt("是否打開:","http://idcbgp.cn/");
?????? if(xinxi==ture)
?????? {window.open('http://idcbgp.cn/','_blank','width=400,height=500,menubar=no,toolbar=no')
?????? }
?????? else
?????? {}
?????? }
??
???
? </script>
?</head>
?<body>
?? <input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />
?</body>
</html>
2016-04-08
因為prompt返回的是值是用戶輸入的內(nèi)容,此處你的代碼已經(jīng)為輸入文本框賦值(prompt第二個參數(shù)即是),如果想要判斷用戶是否已經(jīng)輸入,直接判斷接收變量xinxi是否為null即可。代碼如下:
<script type="text/javascript">?
???
?? function openWindow(){
?????? var xinxi=prompt("是否打開:","http://idcbgp.cn/");
?????? if(xinxi != null)
?????? {window.open('http://idcbgp.cn/','_blank','width=400,height=500,menubar=no,toolbar=no')
?????? }
?????? else
?????? {}
?????? }
? </script>
2016-04-08
?<script type="text/javascript"> ?
? ??
? ? // 新窗口打開時彈出確認(rèn)框,是否打開
? ? // 通過輸入對話框,確定打開的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ? ? function openWindow(){
? ? ? ?var xinxi=prompt("是否打開:","http://idcbgp.cn/");
? ? ? ?if(xinxi==ture)
? ? ? ?{window.open('http://idcbgp.cn/','_blank','width=400,height=500,menubar=no,toolbar=no')
? ? ? ?}
? ??
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
2016-04-08
我運行的行啊