LATEST >>

Welcome Here And Thanks For Visiting. Like Us On Facebook...

EXEIdeas – Let's Your Mind Rock » HTML-CSS-PHP-JavaScript / JavaScript Codes » How To Set Or Specify Referring Page Using Pure JavaScript?

How To Set Or Specify Referring Page Using Pure JavaScript?

How-To-Set-Or-Specify-Referring-Page-Using-Pure-JavaScript
Like you are making a web app or writing any program where you need to know that from which page your visitor or use came to the current page then it is possible via pure plain vanilla javascript.

The reason will be many behind implementing this logic like to display the personalized experience to the use by knowing his trend or can offer something special like coming from any refresher or even in a security point of view can see from where the user clicks to sign-in page etc. All this is simply able to implement.

There are many code snippets available online or on many other blogs and website but everyone is not able to optimize your blog or website so you need some optimized code snippet. So now checkout out code snippet for your blog and website that will give you all features for your desired code. Now grab the ready to use code and paste it where you want.

Get The Referrering/Previous URL To The Current Page:

/****************************************************************************/
// Get The Referrering/Previous URL To The Current Page
/****************************************************************************/
<script type="text/javacript">
var allowedreferrer = "http://www.yoursite.com/referringpagename.htm"; if (document.referrer.indexOf(allowedreferrer) == -1) { alert("You can only access this page from " + allowedreferrer); window.location = allowedreferrer; } </script>

Customization:

document.referrer serves your purpose, but it doesn’t work for Internet Explorer versions earlier than IE9. It will work for other popular browsers, like Chrome, Mozilla, Opera, Safari, etc.

Recommended For You:
How To Add Pure CSS3 Responsive HTML Table Example?

Troubleshooting the Errors

Do it with concentration and patience. Check your alls steps and again and all codes or scripts. If you find any error you can contact us anytime via comment or better via email, We are always here to help you.

Final Words:

That’s all we have. We hope that you liked this article. If you have any problem with this code in your template then feel free to contact us with a full explanation of your problem. We will reply to you as time allows us or If you have any doubts and problem please comment below. We are happy to help you! If you liked this article, Don’t forget to share this with your friends so they can also take benefit from it and leave your precious feedback in our comment form below. Happy development, See you in the next article.

You Like It, Please Share This Recipe With Your Friends Using...

Be the first to write a comment.

Leave a Reply

Your email address will not be published. Required fields are marked *