2011-01-27 147 views
3
function goHome() { 

    if (window.home) { // NS 
    window.home(); 
    } 
    else { // IE and Google Chrome 
    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 
     // ... 
    } 
    } 

} 

但是,我不知道谷歌浏览器中的主页按钮的内置链接。有人有想法吗?如何转发到浏览器的家(谷歌浏览器)

PS。 JavaScript代码不完整,只是一个片段!

回答

4

在Chrome中,主页可能是实际的网址,也可能是新标签页。

所以,chrome://newtab/,但如果一个页面上,你try this,你会提出这个安全错误:

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

(见Chrome的开发工具)中的错误

所以,我不认为这是可能的。我可能是错的,我不是Chrome的专家。

chrome://newtab/确实把你带到正确的地方,如果你把它粘贴到你的地址栏中,但这显然对你没用。

+0

太糟糕了。但是,感谢您的快速响应! – 2011-01-28 12:45:08