gpt4 book ai didi

javascript - 如何转发到浏览器的主页(谷歌浏览器)

转载 作者:可可西里 更新时间:2023-11-01 12:53:29 28 4
gpt4 key购买 nike

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
// ...
}
}

}

但是,我不知道 Google Chrome 中主页按钮的内置链接。有人有想法吗?

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

最佳答案

在 Chrome 中,主页是实际 URL 或新标签页。

所以,它chrome://newtab/,除非你 try this在页面上,您将引发此安全错误:

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

(查看 Chrome 开发者工具中的错误)

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

chrome://newtab/ 如果您将它粘贴到您的地址栏中,确实会将您带到正确的位置,但这显然对您没有用。

关于javascript - 如何转发到浏览器的主页(谷歌浏览器),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4822619/

28 4 0
文章推荐: php - Symfony2 表格 : How to render the same element twice in the same view
文章推荐: html - 如何在