Code to navigate to previous page in history if under same domain
Updated on 17 May
JS onclick="history.go(-1) only if under my domain
<script>
function backClick() {
if(document.referrer.indexOf('mysite.com') >= 0) {
history.go(-1);
}
else {
window.location.href = 'myHomePageUrl'; // this might just be '/' of your site
}
return false;
}
</script>
<br/><a href="" onclick="backClick()">close</a>
Source: https://stackoverflow.com/a/19417145
0 comments for Code to navigate to previous page in history if under same domain