views:

37

answers:

1

I use chrome.extension.getURL for a file, and on the page it is placed, it treats it as 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?

A: 

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.

alanstroop
Of course. Assuming this were a plain link, it'd be `<a href="chrome-extension://ajs8dh8dsfauhdf8auhaffh/blah.js">Blah</a>`, but that links like it is relative. I need this to be treated as absolute.
Cyclone
Anything? I'm not able to find any more information via google...
Cyclone
Can you provide a code snippet showing the use of chrome.extension.getURL and how you are setting the href attribute and the desired results? The chrome-extension://.../blah.js URL is absolute already. A relative URL would not require the protocol (http) or the domain (example.com) and is generally based on where the current page lives or via the HTML <base/> tag.
alanstroop
http://ajaxify.com/run/favicon/favicon.js is what I am using, it sets the favicon url to a chrome-extension url.
Cyclone