开发者

Urls treated as relative urls when using chrome-extension link?

开发者 https://www.devze.com 2023-01-02 05:09 出处:网络
I use chrome.extension.getURL for a file, and on the page it is placed, it treats it as 开发者_StackOverflow社区a relative url (e.g. http://example.com/chrome-extension://ajs8dh8dsfauhdf8auhaffh/blah.

I use chrome.extension.getURL for a file, and on the page it is placed, it treats it as 开发者_StackOverflow社区a relative url (e.g. http://example.com/chrome-extension://ajs8dh8dsfauhdf8auhaffh/blah.js)

How can I make it treat it as an absolute URL instead? It is placed into the href component of a tag.

EDIT: I've seen people's plugins do this for CSS, so I know it is possible. Maybe not for href attributes?


chrome.extension.getURL should return a URL that starts with chrome-extension://. For example if you did chrome.extension.getURL("blah.js"); the value returned would be similar to "chrome-extension://ajs8dh8dsfauhdf8auhaffh/blah.js". This URL points to a local file stored in the extension's directory that is created when the extension is installed. The "ajs8dh8dsfauhdf8auhaffh" is a hash representing your extension to chrome. You're obviously getting something close to that, but the question is why is your's prefixed with "http://example.com/". I would check how you are setting the href attribute.

0

精彩评论

暂无评论...
验证码 换一张
取 消