Advertisement
rAthus

Fonction "retour" universelle

Mar 6th, 2017 (edited)
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function retour() {
  2.     if (document.referrer && document.referrer.indexOf(window.location.hostname)>=0) {
  3.         history.go(-1);
  4.         setTimeout(function() {
  5.             location.href = document.referrer; 
  6.         },500);
  7.     }
  8.     else {
  9.         window.location.href = 'mapage.php';
  10.     }
  11. }
  12.  
  13. // ou sinon, en inline, ajouter sur la balise <a> d'un lien : onclick="javascript:if(document.referrer&&document.referrer.indexOf(window.location.hostname)>=0){history.go(-1);setTimeout(function(){location.href=document.referrer;},500);}else{window.location.href=this.href;}return;"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement