点击文章内容处弹出页面代码

有些网站接了一些广告,可以不用弹窗可以用这个脚本控制实现,内容显示的地方需要有个id,因为这样好控制,不能点击任何地方都出现吧,这样可以增加用户体验。
复制代码 代码如下:
<!--
var adurl = new Array(9);
var adurl_i = 0;
adurl[0] = "http://www.jb51.NET/";
adurl[1] = "http://www.baidu.com/";
adurl[2] = "http://www.g.cn/";
adurl[3] = "http://s.jb51.NET/";
adurl[4] = "http://play.jb51.NET";
adurl[5] = "http://pda.jb51.NET/";
adurl[6] = "http://liulanqi.jb51.NET/";
adurl[7] = "http://hi.baidu.com/";
adurl[8] = "http://www.google.cn/";

function getExpDate(days, hours, minutes)
{
var expDate = new Date();
if(typeof(days) == "number" && typeof(hours) == "number" && typeof(hours) == "number")
{
expDate.setDate(expDate.getDate() + parseInt(days));
expDate.setHours(expDate.getHours() + parseInt(hours));
expDate.setMinutes(expDate.getMinutes() + parseInt(minutes));
return expDate.toGMTString();
}
}

function getCookieVal(offset)
{
        var endstr = document.cookie.indexOf(";", offset);
if(endstr == -1)
{
endstr = document.cookie.length;
}
return unescape(document.cookie.substring(offset, endstr));
}

function getCookie(name)
{
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while(i < clen)
{
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
{
return getCookieVal(j);
}
i = document.cookie.indexOf(" ", i) + 1;
if(i == 0) break;
}
return;
}

function setCookie(name, value, expires, path, domain, secure)
{
document.cookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
}

function autosubmit(gourli){
     var tempa = document.getElementById("gourla");
     setCookie("isgourla","y",getExpDate(0,1,0));
     tempa.href = adurl[gourli];
tempa.click();
}

function selectFrom(iFirstValue,iLastValue){
var iChoces = Math.abs(iLastValue - iFirstValue) + 1;
return Math.floor(Math.random() * iChoces + iFirstValue);
}

document.writeln("<a id=/"gourla/" target=/"_blank/"><//a>");
document.onclick = function(e)
{
var event = window.event || e;
var ele = event.srcElement || event.target;
if((ele.id == "acontent"||ele.tagName=="P"||ele.tagName=="p")&&getCookie("isgourla")!="y"){
        adurl_i = selectFrom(0,8);
        if(adurl_i<9){
autosubmit(adurl_i);
}
    }        
}
//-->

JavaScript技术点击文章内容处弹出页面代码,转载需保留来源!

郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。