為什么這個(gè)不行啊
為什么這不可以?
<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("是否打開(kāi):","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="新窗口打開(kāi)網(wǎng)站" onclick="openWindow()" />
?</body>
</html>
2016-04-08
因?yàn)閜rompt返回的是值是用戶輸入的內(nèi)容,此處你的代碼已經(jīng)為輸入文本框賦值(prompt第二個(gè)參數(shù)即是),如果想要判斷用戶是否已經(jīng)輸入,直接判斷接收變量xinxi是否為null即可。代碼如下:
<script type="text/javascript">?
???
?? function openWindow(){
?????? var xinxi=prompt("是否打開(kāi):","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"> ?
? ??
? ? // 新窗口打開(kāi)時(shí)彈出確認(rèn)框,是否打開(kāi)
? ? // 通過(guò)輸入對(duì)話框,確定打開(kāi)的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
? ? //打開(kāi)的窗口要求,寬400像素,高500像素,無(wú)菜單欄、無(wú)工具欄。
? ? ? function openWindow(){
? ? ? ?var xinxi=prompt("是否打開(kāi):","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="新窗口打開(kāi)網(wǎng)站" onclick="openWindow()" />?
2016-04-08
我運(yùn)行的行啊