摘要:
经常上网的朋友可能会到过这样一些网站,一进入首页立刻会弹出一个窗口,或者按一个连接或按钮弹出,通常在这个窗口里会显示一些注意事项、版权信息、警告、欢迎光顾之类的话或者作者想要特别提示的信息。其实制作这样的页面效果非常的容易,只要往该页面的HTML里加入几段Javascript代码即可实现。
关键字:
弹窗 正文:
E 5+、Firefox 1.0、Mozilla 1.7.5、Netscape 7.2、Opera 7.23 下测试正常,但目前没有"冲破"Firefox的拦截。
*/
演示地址 :http://bbs.cncome.com/click.html
将下面的代码保存为一个.JS文件
CODE:
/**
* 定义ForceWindow类构造函数
* 无参数
* 无返回值
*/
function ForceWindow ()
{
if (!(this.isMsie = (/MSIE/).test(navigator.appVersion)))
{
this.f = document.createElement("FOrm");
this.f.target = "_blank";
this.f.method = "post";
document.documentElement.insertBefore(this.f, document.documentElement.childNodes[0]);
}
}
/**
* 定义pop方法
* 参数sUrl:字符串,要打开窗口的URL。
* 无返回值
*/
ForceWindow.prototype.pop = function (sUrl)
{
if (this.isMsie)
{
var dialogConent = "about:";
dialogConent += "<a href=" + sUrl + " target=_blank id=iecn style=display:none;>iecn</a>";
dialogConent += "<script language=JavaScript type=text/javascript>";
dialogConent += "document.getElementById(iecn).click();window.close();</script>";
window.showModalDialog(dialogConent, "", "width:1px;height:1px;left:0px;top:0px;");
}
else
{
this.f.action = sUrl;
this.f.submit();
}
}
/**
* 实例化一个ForceWindow对象并做为window对象的一个子对象以方便调用
* 定义后可以这样来使用:window.force.pop("URL");
*/
window.force = new ForceWindow();
测试部分.
CODE:
<html>
<head>
<title>ForceWindow测试</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<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://bbs.cncome.com");
}
</script>
</head>
<body>
<h3>强制弹出窗口测试</h3>
<p>打开这页,如果弹出了Blue DOWNLOAD System论坛,即表示正常.顺带去我的论坛看看了,^_^</p>
<button onclick="window.force.pop(http://bbs.cncome.com);">
HI,宝贝,来点我撒~~ :-)</button>
</body>
</html>
4.1、24小时弹出一个窗口的代码
<SCRIPT LANGUAGE="javascript">
<!-- NETBEI.COM
var Time=86400; //设置每次弹出的相格的时间以秒为单位,现在是一天
function Set(){
var Then=new Date();
Then.setTime(Then.getTime()+Time*1000);
documents.cookie="netbei=1;expires="+Then.toGMT
[1][2][3][4][5][6][7][8][9][10][11]