Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Avoid displaying history back if referrer is from different domain
<html>
<div id="breadcrumbs_back" style="display: none">
<button class="button" onclick="history.go(-1); return false"><span><span><?php echo $this->__('Back') ?></span></span></button>
</div>
<script type="text/javascript">
var breadcrumbs_back = $('breadcrumbs_back');
if(breadcrumbs_back) {
var referrer_host = document.referrer.split('/')[2];
var host = '<?php echo $_SERVER['HTTP_HOST'] ?>';
if(referrer_host && referrer_host == host) {
$('breadcrumbs_back').show();
}
else {
$('breadcrumbs_back').remove();
}
}
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment