Created
June 25, 2013 15:28
-
-
Save llacom/5859402 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- START POPUP --> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> | |
<script src="/jquery.cookie.js"></script> | |
<script> | |
function popunder(url, width, height, name_popunder) { | |
// On désactive le popunder sur les sites mobiles | |
if (typeof window.DetectMobileLong == 'function' && typeof window.DetectTierTablet == 'function') { | |
if(DetectMobileLong() || DetectTierTablet()) | |
return false; | |
} | |
var chromeVS = /chrome\/(\d\d)/gi.exec(navigator.userAgent) || 0; | |
var props = 'width=' + width + ', height=' + height, name_popunder; | |
if (navigator.userAgent.indexOf('opera') !== -1) { | |
props += ', scrollbars=no, menubar=no, location=no, directories=no'; | |
} | |
ghost = window.open(url, '_blank', props); | |
try { | |
ghost.blur(); | |
} catch (e) {} | |
if (parseInt(chromeVS[1], 10) >= 23) { | |
document.poltergeist = document.createElement('a'); | |
document.poltergeist.href = "javascript:window.open('', '', '').close();document.body.removeChild(document.poltergeist)"; | |
document.body.appendChild(document.poltergeist).click(); | |
} else { | |
ghost.window.open('about:blank').close(); | |
} | |
return self.focus(); | |
} | |
function capped_popunder(url, width, height, name_popunder, nb_clicks, hours_cookie) { | |
var cookie_name = name_popunder; | |
var cookie_click_name = name_popunder+'_clicks'; | |
var date = new Date(); | |
date.setTime(date.getTime() + (hours_cookie * 60 * 60 * 1000)); | |
if(!jQuery.cookie(cookie_name)) { | |
// On récupère le nombre de clics déjà effectués | |
var clicks = jQuery.cookie(cookie_click_name); | |
if(!clicks) | |
clicks = 0; | |
jQuery('body').mouseup(function() { | |
clicks++; | |
jQuery.cookie(cookie_click_name, clicks, {expires: date, path: '/'}); | |
if(clicks == nb_clicks) { | |
jQuery.cookie(cookie_name, 'true', {expires: date, path: '/'}); | |
popunder(url, width, height, name_popunder); | |
} | |
return true; | |
}); | |
} | |
} | |
jQuery.noConflict(); | |
jQuery(document).ready(function($) { | |
capped_popunder("http://resultat-officiel.com/frame/alert-sms-2013.php", 1000, 500, "result-cookie", 5, 1); | |
}); | |
</script> | |
<!-- END POPUP --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment