Sending user to their browser's Home Page using Javascript

后端 未结 5 1115
庸人自扰
庸人自扰 2020-11-28 15:15

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.

5条回答
  •  孤独总比滥情好
    2020-11-28 15:42

    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/

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


    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:

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

提交回复
热议问题