Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open url as "chrome-extension" in web page?

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 ?

like image 790
dev.knockout Avatar asked Oct 23 '25 06:10

dev.knockout


1 Answers

This 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.

like image 151
smnbbrv Avatar answered Oct 25 '25 19:10

smnbbrv



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!