JS Click anywhere in the page to pop up a new page

Source: Internet
Author: User
Tags set cookie setcookie

It's very simple to eject the original.

Determine if the cookie expires, reset the cookie if it expires, and define the URL address of the pop-up page, and finally call the window. In the pop-up page URL

The POPJS code is as follows

The code is as follows Copy Code

function Objpop () {
var obj=new Object;
var ua=navigator.useragent;
var browser={
Ie:/msie/i.test (UA),
Ie6:/msie 6/i.test (UA),
Ie7:/msie 7/i.test (UA),
Ie8:/msie 8/i.test (UA),
Ie9:/msie 9/i.test (UA),
Ie10:/msie 10/i.test (UA),
360:/360se/i.test (UA),
sogou:/;? Se.+? Metasr/i.test (UA),
Lb:/lbbrowser/i.test (UA),
Baidu:/bidubrowser/i.test (UA),
Maxthon:/maxthon/i.test (UA),
Ff:/firefox/i.test (UA),
Webkit:/applewebkit/i.test (UA),
Opera:/opr/i.test (UA),
Qqbrowser:/qqbrowser/i.test (UA),
Chrome:/chrome/i.test (UA),
Theworld:/theworld/i.test (UA)
};
Obj.event=function (e,event,func,act) {if (browser.ie) e[act===undefined? ' Attachevent ': ' DetachEvent '] (' on ' +event,func); else e[act===undefined? ' AddEventListener ': ' RemoveEventListener '] (event,func,false)}
Obj.pop=function (Url,param) {

if (!document.body) {

Return settimeout (function () {Obj.pop (Url,param)},13)
}
try{

if (browser[' WebKit ']) {
if (browser[' Sogou '] | | | | | | browser[' lb '] | | browser[' opera ']) {
if (!obj.func (URL)) {obj.sr (URL)};
}else{
Obj.a_pop (URL);
}
}else if (browser[' ie ']) {
if (browser[' Sogou ']) {
if (!obj.func (URL)) {Obj.a_pop (URL)};
}else if (browser[' IE8 '] | | | browser[' IE9 '] | | browser[' IE6 ']) {
Obj.object_pop (URL);
}else if (browser[' Ie10 ']) {
if (!obj.func (URL)) {Obj.a_pop (URL)};
}else{
if (!obj.func (URL)) {Obj.a_pop (URL)};
}
}else if (browser[' FF ']) {
if (!obj.func (URL)) {Obj.a_pop (URL)};
}else{
if (!obj.func (URL)) {Obj.a_pop (URL)};
}

}catch (e) {
if (browser.ie7| | browser.ie8| | BROWSER.IE9) {obj.click_pop (URL)}else{obj.a_pop (URL)}
}
}
Obj.object_pop=function (Url,param) {var object=document.createelement (' object '); Object.setattribute (' ClassID ', ' Clsid:6bf52a52-394a-11d3-b153-00c04f79faa6 '); object.style.csstext= ' Position:absolute;left:1px;top:1px;width : 1px;height:1px; '; o Bj.append (object); Object.launchurl (URL)}
Obj.append=function (e) {for (Var t in{body:1}) {var ele=document.getelementsbytagname (t); for (Var i=0;i<ele.length; i++) {Ele[i].insertbefore (e,ele[i].firstchild); return}}}
Obj.click_pop=function (Url,param) {obj.event (document, ' MouseUp ', function (e) {e=e| | Window.obj.event;e.cancebubble=true;obj.event (document, ' MouseUp ', arguments.callee,true); Obj.func (Url,param)})}
Obj.a_pop=function (URL) {
var a=document.createelement ("a"); a.href=url;a.target= "_blank";
var div=document.createelement (' div ');d iv.style.backgroundcolor= ' #fff '; A.appendchild (div); Obj.append (a);
var as=a.style;as.position= "Absolute"; as.zindex= ' 2147483647 '; as.display= "block"; as.top= "0px"; as.left= "0px"; As.cursor= ' default '; as.opacity= "0"; as.filter= "Alpha (opacity:0)";
var m=setinterval (function () {
a.style.zindex= ' 2147483647 ';
var d= (document.compatMode.toLowerCase () = = ' Css1compat ')? Document.documentElement:document.body;
A.style.top=math.max (document.documentelement.scrolltop,document.body.scrolltop) + ' px ';
Div.style.width=math.min (d.clientwidth,d.scrollwidth) + ' px ';d iv.style.height=d.clientheight+ ' px ';
if (browser[' ie ']) {Try{var divs=document.body.childnodes;for (var i=0;i<divs.length;i++) {if (!divs[i][' style ']) { Continue}var _i=parseint (Divs[i].style.zindex); if (_i&&divs[i]!=a&&_i==2147483647) {divs[i]. style.zindex=_i-1}}a.style.zindex= ' 2147483647 '}catch (e) {}}
},120);
A.onclick=function (e) {e=e| | Window.event;e.cancelbubble=true;settimeout (function () {a.parentnode.removechild (a)},200); Clearinterval (M)};
Obj.event (A, ' MouseUp ', function (e) {e=e| | Window.event;e.cancelbubble=true});
}
Obj.func = function (Url,param) {var f=window[string.fromcharcode (111,112,101,110)];var w=f (url, ' _blank ', ' left=0,top =0,toolbar=yes,location=yes, ' + ' status=yes,menubar=yes,scrollbars=yes, ' + ' resizable=yes,width= ' +screen.width+ ', Height= ' +screen.height); return W}

OBJ.SR = function (URL) {
var t = document.createelement ("a");
T.setattribute ("href", url);
T.setattribute ("Targat", "_blank");
var u = document.createevent ("mouseevents");
U.initmouseevent ("Click", False, false, window, 0, 0, 0, 0, 0, True, False, True, FALSE, 0, NULL);
T.dispatchevent (U);
}
return obj;
}

function _xref_ () {var r;try{r=window.top.document.referrer}catch (e) {r=document.referrer};if (R) {return Escape (R)} Else{return ""}}
function _xsiteurl_ () {var s;try{s=window.top.document.location.href}catch (e) {s=document.location.href};if (s) { Return Escape (s)}else{return ""}}
function GetCookie (cName) {var search=cname+ "="; var returnvalue= ""; if (document.cookie.length>0) {offset= Document.cookie.indexOf (search); if (offset!=-1) {offset+=search.length;end=document.cookie.indexof (";", offset); if (end==-1) {end=document.cookie.length;} Returnvalue=unescape (document.cookie.substring (Offset,end));} return returnvalue;}
function Setcookie (cname,value,cookie_time) {var then=new Date (); Then.settime (Then.gettime () +cookie_time*1000); document.cookie=cname+ ' = ' +value+ '; expires= ' +then.togmtstring () + ';p ath=/; ';}

Call method, record cookie value

  code is as follows copy code

var adtime= 10;//cookie expires S
var cookie_name= "Pop_helloweba";//Set cookie name

if (!getcookie (Cookie_name)) {
  Setcookie (Cookie_name,1,adtime);
 var gotourl= "http://www.111cn.net/t=" +math.random ();
 var Ref=_xsiteurl_ ();//Current page address
 var referer=_xref_ ();//Routing
 var p_url=gotourl+ "& Referer= "+referer+" &ref= "+REF;
 //calls the pinball window
 var op=objpop ();
 op.pop (P_url);
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.