DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Chara has posted 50 posts at DZone. View Full User Profile

Specify Referring Page in JavaScript

02.12.2013
| 3635 views |
  • submit to reddit
<!-- source: http://www.apphp.com/index.php?snippet=javascript-specify-referring-page -->
<script type="text/javascript">
   var allowed_referrer = "http://www.yourdomain.com/referring_page_name.html"; 
   if(document.referrer.indexOf(allowed_referrer) == -1){
      alert("You can access this page only from " + allowed_referrer);
      window.location = allowed_referrer;
   }
</script>
This script informs your visitor that a given page may be reached only from the page that you specify. Paste this code before the ending tag on the page:

Comments

Michael Molo replied on Wed, 2013/02/13 - 3:22am

http://bluaccessories.com/