History.back only if the link to the same site

I want to display the back button using history.back, but it should only be displayed if the history page is within the same website / domain. Thus, it should not be displayed if the source of the links, for example. google.com Could not find a working solution.

Is it possible?

thanks

+4
source share
1 answer

Link in javascript is complicated because different browsers support it differently. My preferred method is to catch the referrer using the code behind any language that I use to create the page and then pass it to the page as a javascript variable. C # example:

<script language="javascript" type="text/javascript"> var referer = '<%= Request.UrlReferrer %>'; </script> 
+1
source

All Articles