How to get previous page URL using jQuery
jQuery code to get the previous page URL. The referrer property returns the URL of the document that loaded the current document.
$(document).ready(function() { var referrer = document.referrer; });
The referrer property is supported in all major browsers. But there is a problem here. It is quite possible that Page URL is shared through social media, email or accessed using direct link. So in that case, there is no referrer.
$(document).ready(function() { if(document.referrer.indexOf(window.location.hostname) != -1){ var referrer = document.referrer; } });
Feel free to contact me for any help related to jQuery, I will gladly help you.