Oh yeah, you'll have to actually do this request in the extension, not
in the content script (because content scripts can't do cross-origin
XHR).

So you'll have to actually use content script messaging to request
from the extension the source of the file to eval, then pass it back
to the content script to eval.

See here for more on content script messaging:

http://code.google.com/chrome/extensions/content_scripts.html#messaging

- a

On Tue, Oct 13, 2009 at 2:33 PM, Edwin Khodabakchian
<[email protected]> wrote:
>
> Arron,
>
> Thanks for your responsiveness. I tried to implement your suggestion
> but I get an error when I try to use XMLHttpRequest:
> Uncaught Error: NETWORK_ERR: chrome-extension://
> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/include-gc-all.js XMLHttpRequest
> Exception 101
>
> Is there anything special which need to be set on XMLHttpRequest to be
> able to load chrome-extension urls?
>
> Thank you,
> Edwin
>
>
>
>
>
> On Oct 13, 12:28 pm, Aaron Boodman <[email protected]> wrote:
>> Yes. You can use chrome.extension.getURL("path/to/foo.js") to get the
>> full URL to a script file inside your extension. Once you have that,
>> you can fetch it with XMLHttpRequest, then eval() the contents.
>>
>> - a
>>
>> On Tue, Oct 13, 2009 at 12:23 PM, Edwin Khodabakchian
>>
>> <[email protected]> wrote:
>>
>> > Hi,
>> > Is there any way in a content script to dynamically load scripts
>> > packaged in the extension? The goal here is instead of listing a large
>> > number of js files in the manifest.json and having to load everything
>> > at first?
>> > Thanks,
>> > Edwin
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Chromium-extensions" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/chromium-extensions?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to