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");
});