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

有些网站接了一些广告,可以不用弹窗可以用这个脚本控制实现,内容显示的地方需要有个id,因为这样好控制,不能点击任何地方都出现吧,这样可以增加用户体验。

复制代码 代码如下:


<!--
var adurl = new Array(9);
var adurl_i = 0;
adurl[0] = "https://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);
}
    }        
}
//-->

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wjyjgp.html