所属分类:HTML网页,JS语言与代码
来源http://www.im286.com/thread-4232404-1-1
[不侵占父窗口] [代码重修版] [新增对话框弹窗模式]
代码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小时退弹一次,
[不侵占父窗口] [代码重修版] [新增对话框弹窗模式]
代码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小时退弹一次,