开发者

How to forward to browser's home (Google Chrome)

开发者 https://www.devze.com 2023-02-07 07:43 出处:网络
function goHome(){ if (window.home) { // NS window.home(); } else { // IE and Google Chrom开发者_运维百科e
function goHome()  { 

  if (window.home) { // NS
    window.home();
  }
  else { // IE and Google Chrom开发者_运维百科e
    if (navigator.appVersion.split("MSIE")[1] <= 7) { // IE 4-7
      window.location = "about:home";
    }
    else if (window.location.href) { // Google Chrome
      window.location.href = "??????????";            // <<-- what is the built-in 
    }                                                 //      link for the home button
    else { // IE 8, 9
      // ...
    }
  }

}

However, I do not know the built-in link for the home button in Google Chrome. Does anybody has an idea?

PS. The JavaScript code is incomplete and just a snippet!


In Chrome, the home page is either an actual URL, or the New Tab page.

So, it would be chrome://newtab/, except that if you try this on a page, you'll raise this security error:

Not allowed to load local resource: chrome://newtab/

(see the error in Chrome's Developer Tools)

So, I don't think it's possible. I could be wrong, I'm no expert on Chrome.

chrome://newtab/ does take you to the right place if you paste it into your address bar, but that is obviously useless to you.

0

精彩评论

暂无评论...
验证码 换一张
取 消