到底哪兒錯(cuò)了...
<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("是否要打開(kāi)一個(gè)新網(wǎng)頁(yè)?");
????? if(message==true){
????????? var website=prompt("請(qǐng)輸入網(wǎng)站地址:","http://idcbgp.cn/");
????????? if(website!=null){
????????????? window.open('website','_blank','width=400,height=500,top=0,left=0,menubar=no,toolbar=no,scrollbars=yes,status=yes');
????????? }
????????? else{
????????????? alert("再見(jiàn)吧朋友");
????????? }
????? }
????? else{
????????? alert("再見(jiàn)吧孩子");
????? }
? }
? openWindow();
? </script>
?</head>
?<body>
?? ?? <input type="button" value="新窗口打開(kāi)網(wǎng)站" onclick="openWindow()" />
?</body>
</html>
運(yùn)行不了,有大神能幫忙指出錯(cuò)誤嗎?
2016-03-16
第一:?window.open('website','_blank','width=400,height=500,top=0,left=0,menubar=no,toolbar=no,scrollbars=yes,status=yes');
website的單引號(hào)應(yīng)該去掉。
第二:?openWindow();
? </script>?
這里不需要再調(diào)用openWindow()了,函數(shù)是通過(guò)點(diǎn)擊觸發(fā)的。不用再調(diào)用
第三:這節(jié)練習(xí)不驗(yàn)證代碼,你把代碼保存成.html 直接在瀏覽器就可以運(yùn)行了。不需要依賴這里的環(huán)境
2016-03-16
window.open('website',
這里website是變量,不需要添加''包括。
2016-03-16
window.open('website','_blank','width=400,height=500,top=0,left=0,menubar=no,toolbar=no,scrollbars=yes,status=yes');?
這里website是變量,不需要添加''包括。