一个强制弹窗代码
将下面的代码保存为一个.JS文件
复制内容到剪贴板
代码:
- function ForceWindow ()
- {
- if (!(this.isMsie = (/MSIE/).test(navigator.appVersion)))
- {
- this.f = document.createElement_x("FORM");
- this.f.target = "_blank";
- this.f.method = "post";
- document.documentElement.insertBefore(this.f, document.documentElement.childNodes[0]);
- }
- }
- ForceWindow.prototype.pop = function (sUrl)
- {
- if (this.isMsie)
- {
- var dialogC;
- dialogConent += "<a href='" + sUrl + "' target='_blank' id='iecn' style='display:none;'>iecn</a>";
- dialogConent += "<script language='JavaScript' type='text/javascript'>";
- dialogConent += "document.getElementByIdx_x('iecn').click();window.close();</script>";
- window.showModalDialog(dialogConent, "", "width:1px;height:1px;left:0px;top:0px;");
- }
- else
- {
- this.f.action = sUrl;
- this.f.submit();
- }
- }
复制代码
window.force = new ForceWindow();
测试部分.
复制内容到剪贴板
代码:
- <html>
- <head>
- <title>ForceWindow测试</title>
- <meta http-equiv="Content-Type" c>
- <script language="JavaScript" type="text/javascript"
- src="ForceWindow-1.0.2.iclass.js"></script>
- <script language="JavaScript" type="text/javascript">
- window.onload = function ()
- {
- window.force.pop("http://www.m1938.com");
- }
- </script>
- </head>
- <body>
- <h3>强制弹出窗口测试</h3>
- <p>打开这页,如果弹出了Blue DOWNLOAD System论坛,即表示正常.顺带去我的论坛看看了,^_^</p>
- <button >
- HI,宝贝,来点我撒~~ :-)</button>
- </body>
- </html>
复制代码
|