Is it possible to get a browser's home page using Javascript?
I'd like to place a link on a page that goes to the home page set in the browser.
Is it possible to get a browser's home page using Javascript?
I'd like to place a link on a page that goes to the home page set in the browser.
For FF and the like:
window.home();
For IE:
location = "about:home";
Default home page (default new tab) URL:
Google Chrome:
Firefox and IE:
Opera:
Safari:
To find out the default home page URL of your browser, go to your home page and type
location.href
in the console. Note that the browser might redirect you to your locale, so you'll need to find out the page before redirection (it happens on Chrome).If you're using this browser detection code you can use this one-liner to get the correct url:
Browser detection code JSFiddle: https://jsfiddle.net/oriadam/ncb4n882/
window.home() didn't work for me in FF37, but this was fine:
Not sure if there is a cross-browser solution. In IE you can use the HomePage behavior and call navigateHomePage.
EDIT: simplified answer
Identify browsers and:
Call window.home(); for all browsers
Call window.location.href = "about:home"; for IE
To do so you can use http://jquery.thewikies.com/browser/
Other solutions:
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:
and use this in the script above to call the correct function: