If you load the script at document_end, you'll have a change to inject
JS when the DOM is already there but nothing else is executed yet,
right?

On Mon, Dec 21, 2009 at 6:43 PM, Kasem Marifet <[email protected]> wrote:
> Thanks Evgeny,
> Adding a script element to the page won't do it. Couple of reasons:
>   - Imagine a script that is in the head of the page and that script needs
> to access the api provided by the extension. It will be too late by the time
> extension will add the library.js.
>   - I load the content_script of the extension at document_start. The dom is
> not ready then
> Kasem
> On Mon, Dec 21, 2009 at 10:19 AM, Evgeny Shadchnev
> <[email protected]> wrote:
>>
>> Since the extension code and the page live in isolated worlds and
>> cannot communicate directly, you can try injecting script elements
>> into the dom. In your content script try something along the lines of
>>
>>  var e = document.createElement("script");
>>  e.src = chrome.extension.getURL('my_library.js');
>>  e.type="text/javascript";
>>  document.getElementsByTagName("head")[0].appendChild(e);
>>
>> I didn't try this but I'm pretty sure it should work.
>>
>> Evgeny
>> InvisibleHand
>>
>> On Mon, Dec 21, 2009 at 6:16 PM, kasemmarifet <[email protected]>
>> wrote:
>> > Anyone?
>> >
>> > On Dec 17, 4:46 pm, kasemmarifet <[email protected]> wrote:
>> >> Hi,
>> >>
>> >> I'd like to know if it is possible to build a Chrome Extension that
>> >> would provide some javascript apis to the web pages. For example
>> >> provide common utility js functions that scripts from the web pages
>> >> can call?
>> >>
>> >> I looked at the content_scripts and background pages but none of them
>> >> seem to provide such a functionality.
>> >>
>> >> Related to this, what is the best way to share information between the
>> >> extension and a web page?
>> >>
>> >> Thanks,
>> >>
>> >> Kasem
>> >
>> > --
>> >
>> > 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.
>> >
>> >
>> >
>
>

--

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