需要从Chrome扩展程序的页面内直接链接到Chrome内部页面 [英] Need to link directly to a Chrome internal page, from within a page of a Chrome Extension
问题描述
我刚刚花了7个小时试图找到一种直接链接到Chrome内部页面的方式。现在我已经放弃了。我刚刚指示人们右键单击并在新标签页中打开。
我已经尝试了所有内容,从html到css到javascript,但没有任何工作。即使右键单击链接并在新标签中打开链接,也没有任何反应。
Javascript尝试失败:
< div class =links>
< a href =chrome:// net-internals /onclick =window.open('chrome:// net-internals /');> TESTAA< / a>
< / div>
和
< div class =links>
< a href =chrome:// net-internals /onclick =window.location('chrome:// net-internals /');> TESTAA< / a>
< / div>
没有错误页面。点击时根本没有任何反应。如果您强制使用 target =_ blank
在新标签中打开它,它只会打开一个空白标签。
< H1>更新!已解决!
-----步骤1 -----
在background.html页面中放置以下代码(在manifest.json中调用background.html):
函数openNetInternals (){
chrome.tabs.create({url:'chrome:// net-internals /'});
}
-----步骤2 -----
将此代码放入链接中(在html页面中):
< a href =chrome:// net-internals /onclick =chrome.extension.getBackgroundPage()。openNetInternals()> Net< / a>
-----步骤3 -----
确保刷新扩展名。
现在就可以使用了。
此链接可以从您的扩展程序或您的网站获得吗?如果来自扩展程序,请尝试使用 chrome.tabs 模块:
chrome.tabs.create({url:'chrome:// net-internals /'});
在后台页面创建如下功能:
函数openNetInternals(){
chrome.tabs.create({url:'chrome:// net-internals /'});
}
当您点击链接时,从您的自定义开始页面调用它:
chrome.extension.getBackgroundPage()。openNetInternals();
相关文档 here 。
I just spent the last 7 hours straight trying to find a way to link directly to a Chrome internal page. For now I have given up. I just instructed people to "right-click and open in new tab".
I have tried everything, from html to css to javascript, but nothing is working. Nothing happens when I click the link, even though right-clicking the link and opening it in a new tab works perfect.
Javascript failed attempts:
<div class="links">
<a href="chrome://net-internals/" onclick="window.open('chrome://net-internals/');">TESTAA</a>
</div>
and
<div class="links">
<a href="chrome://net-internals/" onclick="window.location('chrome://net-internals/');">TESTAA</a>
</div>
There is no error page. Simply nothing happens when you click. If you force it to open in a new tab using target="_blank"
, it only opens a blank tab.
UPDATE! SOLVED!
----- STEP 1-----
Place the following code in the background.html page (background.html is called in the manifest.json):
function openNetInternals() {
chrome.tabs.create({url: 'chrome://net-internals/'});
}
----- STEP 2 -----
Put this code for the link (in the html page):
<a href="chrome://net-internals/" onclick="chrome.extension.getBackgroundPage().openNetInternals()">Net</a>
----- STEP 3 -----
Make sure to refresh the extension. It will work now.
Is this link available from your extension or from your website? If from extension then try using chrome.tabs module:
chrome.tabs.create({url: 'chrome://net-internals/'});
On the background page create function like this one:
function openNetInternals() {
chrome.tabs.create({url: 'chrome://net-internals/'});
}
And call it from your custom start page when link is clicked like this:
chrome.extension.getBackgroundPage().openNetInternals();
Relevant docs here.
这篇关于需要从Chrome扩展程序的页面内直接链接到Chrome内部页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!