一个强制弹出窗口的JavaScript类,存放在JS文件,直接一个函数调用即可,但是此弹出窗口不能自定义样式、宽、高等参数,部分高版本的浏览器已经能够拦截此窗口
js文件定义如下:
/**
* 定义ForceWindow类构造函数
* 无参数
* 无返回值
*/
function ForceWindow ()
{
this.r = document.documentElement;
this.f = document.createElement("FORM");
this.f.target = "_blank";
this.f.method = "post";
this.r.insertBefore(this.f, this.r.childNodes[0]);
}
/**
* 定义open方法
* 参数sUrl:字符串,要打开窗口的URL。
* 无返回值
*/
ForceWindow.prototype.open = function (sUrl)
{
this.f.action = sUrl;
this.f.submit();
}
window.force = new ForceWindow();
调用方法如下:
<script language="javascript">
window.force.open('http://www.sharejs.com');
</script>




