不知道哪里錯了,點擊之后沒有彈出窗口
<!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 mychar=confirm("是否打開?");
? ? // 新窗口打開時彈出確認框,是否打開
? ? ? ? if(mychar==true){
? ? // 通過輸入對話框,確定打開的網(wǎng)址,默認為 http://idcbgp.cn/
? ? ? ? ? ?var mywin=prompt("請確定打開的網(wǎng)址", "http://idcbgp.cn/");
? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ? ? ? ? ?if(mywin=="http://idcbgp.cn/"){
? ? ? ? ? ? ? ?window.open('mywin','_blank',width=400px,height=500px,menubar=no,toolbar=no)
? ? ? ? ? ?}
? ? ? ? }
? ? }
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
2016-08-17
Js方法中的參數(shù)要么是實參,要么是形參。很明顯window的open方法你傳的是實參,而且你希望它接受三個參數(shù),
根據(jù)你的寫法:??window.open('mywin','_blank',width=400px,height=500px,menubar=no,toolbar=no) ?這是6個參數(shù)啊,能不出問題么?還以后面也不加冒號,雖然這不太影響。
2016-08-17
? <script type="text/javascript"> ?
??? function openWindow(){
????? if(confirm("打開新窗口?")){// 新窗口打開時彈出確認框,是否打開
?????? window.open(['http://idcbgp.cn/'],['_blank'],[width=400,height=500]);// 通過輸入對話框,確定打開的網(wǎng)址,默認為 http://idcbgp.cn/
??? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
????? }
??? }
? </script>
2016-08-17
window.open('mywin','_blank',width=400px,height=500px,menubar=no,toolbar=no)中的mywin不用加引號,不然打不開
2016-08-17
window.open('mywin','_blank',width=400px,height=500px,menubar=no,toolbar=no)這行有錯誤!
'width=400px,height=500px,menubar=no,toolbar=no'加上單引號,因為它們統(tǒng)稱為參數(shù)字符竄。
2016-08-17
window.open()方法中的參數(shù)需要在單引號中設(shè)置,加上單引號'height=500px,menubar=no,toolbar=no'