admin管理员组文章数量:1315777
I have one web page and one chrome extension, how can I open url like this chrome-extension://chrome-id/page.html. Here is my code:
$(document).on('click', '#btnOpenChromeExtension', function () {
window.open("chrome-extension://chrome-id/webpage.html", "_blank");
});
But when click, it open new tab in blank page with url is: about:blank. How can I open link is chrome-extension ?
I have one web page and one chrome extension, how can I open url like this chrome-extension://chrome-id/page.html. Here is my code:
$(document).on('click', '#btnOpenChromeExtension', function () {
window.open("chrome-extension://chrome-id/webpage.html", "_blank");
});
But when click, it open new tab in blank page with url is: about:blank. How can I open link is chrome-extension ?
Share Improve this question asked May 6, 2015 at 8:00 dev.knockoutdev.knockout 3992 gold badges5 silver badges12 bronze badges 2- Does it work (or do something else) when you leave out the second parameter? From w3schools: _blank - URL is loaded into a new window. This is default so there's no need to specify it. Still a strange situation... Does the URL you supply lead to the extension when you paste it into the address bar manually? – Nils O Commented May 6, 2015 at 8:17
- @NilsO It work normaly with url contains "http", but it seem to be not work with url contains "chrome-extension" – dev.knockout Commented May 6, 2015 at 8:20
2 Answers
Reset to default 7This is restricted due to the extension policies. You need to add to the extension's manifest.json file the following:
{
...
"web_accessible_resources": [
"page/mypage.html"
],
...
}
Of course, this must be your extension. This is the only way I know to make it work.
Try this:
$(document).on('click', '#btnOpenChromeExtension', function () {
window.location.href = "chrome-extension://chrome-id/webpage.html";
// OR
window.location.replace("chrome-extension://chrome-id/webpage.html");
});
本文标签: javascriptHow to open url as quotchromeextensionquot in web pageStack Overflow
版权声明:本文标题:javascript - How to open url as "chrome-extension" in web page? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741991400a2409177.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论