Specify Referring Page In JavaScript


SUBMITTED BY: Guest

DATE: June 12, 2013, 1:24 a.m.

FORMAT: JavaScript

SIZE: 451 Bytes

HITS: 1536

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

comments powered by Disqus