//定義變量,利用時間精確到秒的數值作爲窗口的名字
var myD = new Date();
var myHours = myD.getHours();
var myMinutes = myD.getMinutes();
var mySeconds = myD.getSeconds();
var win = myHours * 1200 + myMinutes * 20 + Math.floor( mySeconds / 3 );
//新窗口寬度等於屏幕分辨率減去IE兩側邊框的寬度
var wide = window.screen.availWidth-10;
//新窗口高度等於屏幕分辨率減去IE標題欄的高度
var high = window.screen.availHeight-35;
//定義新窗口的樣式
var arg = "menubar=no,toolbar=no,location=no,status=no,resizable=yes,scrollbars=no,width="+wide+",
height="+high+",left=0,top=0";
if (this.name == ''){
this.parent.window.open(this.parent.location,win,arg);
window.opener=null;
window.close();
}
備註說明:
1.先將該腳本保存成一個JS文件,比如full.js,然後包含到需要實現全屏的頁面當中;
2.該腳本在IE6下可以實現無提示自動關閉父窗口同時打開全屏新窗口,IE7下會詢問是否關閉父窗口。
3.如果使用該代碼後發現沒有屏蔽IE的狀態欄,請修改新窗口高度那個變量,增加後面的數值。
補充說明:由於IE7更高的安全性能,目前還沒有實現IE7的頁面全屏,如果您有更好的解決方法,歡迎不吝賜教,謝謝。