Posted By

apphp-snippets on 02/13/13


Tagged

javascript page referring


Versions (?)

Specify Referring Page in JavaScript


 / Published in: JavaScript
 

URL: http://www.apphp.com/index.php?snippet=javascript-specify-referring-page

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:

  1. <script type="text/javascript">
  2. var allowed_referrer = "http://www.yourdomain.com/referring_page_name.html";
  3. if(document.referrer.indexOf(allowed_referrer) == -1){
  4. alert("You can access this page only from " + allowed_referrer);
  5. window.location = allowed_referrer;
  6. }
  7. </script>

Report this snippet  

You need to login to post a comment.