Specify Referring Page in JavaScript

/ Published in: JavaScript
Save to your folder(s)

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:

Copy this code and paste it in your HTML
  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>

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

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.