history.back only if referrer same website
I'd like to display a back button with the help of history.back, but it should only be displayed if the history page is within the same website / domain. So it should not be displayed if referrer is e.g. google.com. Couldn't find a working solution yet.
Is t开发者_JAVA百科his possible?
Thx
Referer in javascript is tricky because different browsers support it differently. My preferred method is to catch the referrer using code behind of whatever language I'm using to produce the page and then pass it into the page as a javascript variable. A C# example:
<script language="javascript" type="text/javascript">
var referer = '<%= Request.UrlReferrer %>';
</script>
精彩评论