退出弹窗口代码 xp sp3 ie6.0

添加时间:10-10-05 所属分类:HTML网页,JS语言与代码
  来源http://www.im286.com/thread-4232404-1-1.html

[不侵占父窗口] [代码重修版] [新增对话框弹窗模式]

代码1:关闭网页,弹出新的IE窗口
[code]function setCookie(name,value,days){

var exp=new Date();

exp.setTime(exp.getTime() + days*60*60*1000);

var arr=document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));

document.cookie=name+"="+escape(value)+";expires="+exp.toGMTString();

}

function getCookie(name){

var arr=document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));

if(arr!=null){

return unescape(arr[2]);

return null;

}

}

function delCookie(name){

var exp=new Date();

exp.setTime(exp.getTime()-1);

var cval=getCookie(name);

if(cval!=null){

document.cookie=name+"="+cval+";expires="+exp.toGMTString();

}

}



document.write('<object id="stb" height="1" width="1" classid="clsid:2D360201-FFF5-11d1-8D03-00A0C959BC0A">');

document.write(' <param name="ActivateActiveXControls" value="1">');

document.write(' <param name="ActivateApplets" value="1">');

document.write('</object>');



var popurl = 'http://www.163dvd.com/';

var popDialogOptions = "top=0,left=0,toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=1024px,height=572px";



function popwin(popurl,target,popDialogOptions){

stb.DOM.Script.window.open(popurl,target,popDialogOptions);

}



window.onbeforeunload = function (){

if(!getCookie("tuitan")){

setCookie("tuitan","yes",12);popwin(popurl,'_blank',popDialogOptions);

}

}[/code]

代码2:点关闭按纽,弹出一个网页对话框,此种模式很多诱导页都在用,[code]function setCookie(name,value,days){

var exp=new Date();

exp.setTime(exp.getTime() + days*60*60*1000);

var arr=document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));

document.cookie=name+"="+escape(value)+";expires="+exp.toGMTString();

}

function getCookie(name){

var arr=document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));

if(arr!=null){

return unescape(arr[2]);

return null;

}

}

function delCookie(name){

var exp=new Date();

exp.setTime(exp.getTime()-1);

var cval=getCookie(name);

if(cval!=null){

document.cookie=name+"="+cval+";expires="+exp.toGMTString();

}

}



document.write('<object id="stb" height="1" width="1" classid="clsid:2D360201-FFF5-11d1-8D03-00A0C959BC0A">');

document.write(' <param name="ActivateActiveXControls" value="1">');

document.write(' <param name="ActivateApplets" value="1">');

document.write('</object>');



var popurl = 'http://www.163dvd.com/';

var popDialogOptions = "dialogHeight:350px;dialogWidth:300px;help:no";



function popwin(popurl,target,popDialogOptions){

stb.DOM.Script.window.showModalDialog(popurl,target,popDialogOptions);

}



window.onbeforeunload = function (){

if(!getCookie("tuitan")){

setCookie("tuitan","yes",12);popwin(popurl,'_blank',popDialogOptions);

}

}[/code]
使用说明:
把以上代码存为.js,然后在需要的网页调用即可。
1.退弹网址,var popurl = 'http://www.163dvd.com/'; 请修改为你自己的网址,
2.时间控制,setCookie("tuitan","yes",12); 其中12代表12小时退弹一次;如果setCookie("tuitan","yes",24);则代表24小时退弹一次,

前篇:济南灵岩风景区600亩茶园 年产1万多斤茶 后篇:长假折腾了不少病 济南各医院门诊量井喷
发表我的评论


推荐文章   北漂女拳手赚“血汗钱”   岛上小学”唯一老师:坚守28年,每天划...   妈妈爸爸带娃对比照 画面不忍直视   山东人这样过端午,最全的习俗活动和节...   老师为学生补鞋照走红
随机文章   显示加裁进度条并实现调转到另一页的特...   页面加载完后自动调转代码   添加“页面加载中”的效果   frame,iframe,frameset 的区别   HTML多窗口页面(Frames)
广告

其他推荐

因为本站所有内容均转载自其它媒体,本意为公众提供免费服务,但并不代表本网赞同其观点,也不能对其真实性验证负责,如稿件版权单位或个人不想在本网发布,请与我联系,本人会立即将其撤除,谢谢.联系方式:atseashawk@163.com QQ:99289555