Sending user to their browser’s Home Page using Javascript

EDIT: simplified answer

Identify browsers and:

  • Call window.home(); for all browsers

  • Call window.location.href =
    “https://stackoverflow.com/questions/1369450/about:home”; for IE

To do so you can use http://jquery.thewikies.com/browser/

The jQuery Browser Plugin is an addon
for jQuery that makes it easy to
uniquely identify your visitors’
browsers.


Other solutions:

 <script language="javascript">
    function gohome(){
      if (typeof window.home == 'function'){ // The rest of the world
        window.home();
      } else if (document.all) { // For IE 
        window.location.href = "https://stackoverflow.com/questions/1369450/about:home";
      } else {
        document.write("<p>Please click on your browser's Home
button.</p>");
      }
    }
  </script>

This is via this website. The poster states that there are issues to target Safari. This can be fixed using this other website.

Using the CSS tricks explained there you can then do:

<script type="text/javascript">
   isSafari3 = false;
   if(window.devicePixelRatio) isSafari3 = true;
</script>

and use this in the script above to call the correct function:

if (typeof window.home == 'function' || isSafari3)

Leave a Comment