Skip to content

Instantly share code, notes, and snippets.

@jney
Created March 25, 2010 14:24
Show Gist options
  • Save jney/343604 to your computer and use it in GitHub Desktop.
Save jney/343604 to your computer and use it in GitHub Desktop.
/***
* How to use it in your html page :
* copy the code and paste it in your page and update param passed to
* Figaro.redirectUrl to desired page. So, Figaro.redirectUrl will
* return new calculated URL.
*
* - Calculated link to pass through
* <a href="#" onclick="window.location.replace(Figaro.redirect)">
* Pass this ad
* </a>
*
* - Automatically redirected after 4 seconds
* <script>
* setTimeout(function(){
* window.location.replace(Figaro.redirectUrl);
* },4000);
* </script>
*
***/
if(typeof window.Figaro == "undefined")
Figaro = {}
Figaro.redirectUrl = (function(url){
var xtref = encodeURIComponent(document.referrer),
xtor = document.location.search.match(/[?|&]xtor=([^&]+)/) ||
document.location.hash.match(/^#xtor=(.+)$/) || "";
if (xtor != "") xtor = "&xtor=" + xtor[1];
return xtref ? (url + "?xtref=" + xtref + xtor) : url;
})("http://www.lefigaro.fr/")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment