Is there any way to get the previous URL in JavaScript? Something like this:
alert(\"previous url is: \" + window.history.previous.href);
document.referrer serves your purpose, but it doesn't work for Internet Explorer versions earlier than IE9.
document.referrer
It will work for other popular browsers, like Chrome, Mozilla, Opera, Safari etc.