How to get the previous page url using jquery?
I am using the following code to get the current page location
$(document).ready(function() {
var path
simple & sweet
window.location = document.referrer;
$(document).ready(function() {
var referrer = document.referrer;
if(referrer.equals("Setting.jsp")){
function goBack() {
window.history.go();
}
}
if(referrer.equals("http://localhost:8080/Ads/Terms.jsp")){
window.history.forward();
function noBack() {
window.history.forward();
}
}
});
using this you can avoid load previous page load
document.referrer is not working always.
You can use:
window.location.origin