网站主页 > 建站教程 >

强悍的退弹代码:xp sp3 ie6.0下不侵占父窗口

来源:博客 时间:2010-01-02 10:28 字体: [ ] 参加站长培训 收藏 我要投稿

代码1:关闭网页,弹出新的IE窗口

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);

        }

}

 


  代码2:点关闭按纽,弹出一个网页对话框,此种模式很多诱导页都在用

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.tianqila.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);
        }
}

 


  使用说明:

  把以上代码存为.js,然后在需要的网页调用即可。

  1.退弹网址,var popurl = 'http://www.tianqila.com/'; 请修改为你自己的网址,

  2.时间控制,setCookie("tuitan","yes",12); 其中12代表12小时退弹一次;如果setCookie("tuitan","yes",24);则代表24小时退弹一次,


 

责任编辑: admin 您的投稿就是对我们最大的支持.
  • 评论加载中...

    发表评论

  • 用户名: 密码: 验证码: 点击我更换图片

  • 头条
  • 推荐