為什么輸入http://www.xianlaiwan.cn/以后打開的不是寬400高500的窗口?
<!DOCTYPE html>
<html>
?<head>
? <title> new document </title>??
? <meta http-equiv="Content-Type" content="text/html; charset=utf8"/>? ?
??
?</head>?
?<body>?
? <input name="button" type="button" value="新窗口打開網站" onclick="openWindow()" />?
?</body>
?<script type="text/javascript">??
? ? function openWindow(){
? ? ? debugger
? ? ? ? var myweb=confirm("是否打開新窗口")
? ? ? ? if(myweb==true)
? ? ? ? {rec2();}
? ? ? ? else
? ? ? ? {document.write("不打開新窗口");}
? ? }
? ? // 新窗口打開時彈出確認框,是否打開
? ? function rec2(){
? ? ? ? var mywebopen=prompt("輸入打開的網址");
? ? ? ? if(mywebopen=="http://www.xianlaiwan.cn/")
? ? ? { window.open('http://www.xianlaiwan.cn/','_self','height=500 width=400 menubar=no,toolbar=no');}
? ? }
? ??
? ? // 通過輸入對話框,確定打開的網址,默認為 http://www.xianlaiwan.cn/
? ?
? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ??
? ??
? </script>?
</html>
2021-08-09
首先應該是blank而不是self,因為self用的是本身窗口的格式,所以再設置高寬就沒用,另外就是瀏覽器不能是全屏,要不然無論設置什么寬高,都是全屏的。