<!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?open=confirm("是否打開");
???
?????if(open==true)
???????{
???????var?ope=prompt("shuru","http://www.xianlaiwan.cn/");}
??????
????????if(ope!=null){
????window.open("ope",'width=400','height=500''_blank','menubar=no','toolbar=no')};
????
????????else{
?????????window.open('?ope','width=400','height=500''_blank','menubar=no','toolbar=no')};
????else
???{?alert("bye");}
???
???}
??</script>?
?</head>?
?<body>?
??<input?type="button"?value="新窗口打開網站"?onclick="openWindow()"?/>?
?</body>
</html>
2015-08-02
花括號嵌套錯亂了。
window.open("ope",'width=400','height=500''_blank','menubar=no','toolbar=no')};這里變量ope是不需要加引號的。后面的參數直接用一對單引號就可以了。
修改后的代碼你看看
<!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?open=confirm("是否打開"); ???? if(open==true){ ??????? var?ope=prompt("shuru","http://www.xianlaiwan.cn/"); ???if(ope!=null){ ??? ?????????window.open(ope,'width=400,height=500,_blank,menubar=no,toolbar=no'); ???????}else{ ?????????????window.open(ope,'width=400,height=500,_blank,menubar=no,toolbar=no'); ???} ?}else{? ?alert("bye"); ????} ??????} ??</script>? ?</head>? ?<body>? ??????<input?type="button"?value="新窗口打開網站"?onclick="openWindow()"?/>? ?</body> </html>