為何彈不出來
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>close()</title>
? <script type="text/javascript">
? function openUrl()
? {
???? var mywin=window.open("http://www.xianlaiwan.cn");
???? var pages=confirm("是否");
???? if(pages==true)
???? {
???????? mywin.close( );
??????? alert("開");
???? }
???? else
???? {
??????? alert("關閉");
???? }
? }
? </script>
</head>
<body>
? <input name = "button2" type = "button" onClick = "openUrl()" value= "是否關閉" />
</body>
</html>
2016-12-20
我測試了一下,你主要是檢查下每句代碼后邊的分號是否是在英文狀態下寫的,然后再看下彈出窗口時窗口內容里的字是否是你想要的。
2016-10-31
:上面代碼在打開新窗口的同時,關閉該窗口,看不到被打開的窗口。
2016-10-27
? <script type="text/javascript"> ?
? ? function openWindow(){
? ? // 新窗口打開時彈出確認框,是否打開
? ? var ifopen = confirm("是否確認打開");
? ? // 通過輸入對話框,確定打開的網址,默認為 http://www.xianlaiwan.cn/
? ? if(ifopen){
? ? var url = prompt("打開網址","http://www.xianlaiwan.cn");
? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ? window.open('url','_blank','width=400,height=500,menubar=no,toolbar=no')
? ? }
? ? }
? </script>?