Skip to content

Instantly share code, notes, and snippets.

@cam-gists
Created July 27, 2012 15:47
Show Gist options
  • Select an option

  • Save cam-gists/3188777 to your computer and use it in GitHub Desktop.

Select an option

Save cam-gists/3188777 to your computer and use it in GitHub Desktop.
JavaScript: Mobile Popunder
///Mobile PopUnder
var uri = "http://lander.com";
var site = "site.com ";
var func = 'firepop("'+uri+'")';
$(document).ready(function() {
$('.content a').attr('onclick', func);
$('.content a').attr('target', '_blank');
});
function cookie_set(value,exdays){
var cookie_name = site + "pop";
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var cookie_value=escape(value) + ((exdays===null) ? "" : "; expires="+exdate.toUTCString() + "; path=/" );
document.cookie=cookie_name + "=" + cookie_value;
}
function cookie_get(){
var cookie_name = "mrpop";
var i,x,y,cookie=document.cookie.split(";");
for (i=0;i<cookie.length;i++)
{
x=cookie[i].substr(0,cookie[i].indexOf("="));
y=cookie[i].substr(cookie[i].indexOf("=")+1);
x=x.replace(/^\s+|\s+$/g,"");
if (x==cookie_name)
{
return unescape(y);
}
}
}
function firepop( uri ){
if( !uri ){uri = "http://www.google.com";}
if( cookie_get() ){}
else {
cookie_set( true, 1 );
document.location.assign( uri );
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment