I don't believe you can expect the script element loading to occur
synchronously, so if "Background" is defined in background.js, it's
not going to be guaranteed to be available just after creating the
element that includes the script (in fact, I wouldn't even expect it
to be).  You might try including code in background.js that has a call
to an initialization function at the bottom of the script.

Hope that helps!

On Dec 5, 10:37 am, starach <[email protected]> wrote:
> Hello,
>
> I'm currently working on extension that allows to add RSS Feeds as
> bookmark folders. ( like in Firefox )
>
> After finishing some scripting I've decided to split the code into
> separated files. When I run it, inside head section everything is
> fine. New lines with script tag are added but it seems to me like they
> have no effect. What I mean is, script files don't want to load
> themselves and as a result I see inside console fallowing error:
> Uncaught ReferenceError: Background is not defined - chrome-
> extension://:id:/script/autoload/background.js:23
>
> function Autoload() {}
> Autoload.aFiles = new Array('options', 'background')
> Autoload.includeScript = function($sFile)
> {
>         if(document.createElement && document.getElementsByTagName)
>         {
>                 $Head = document.getElementsByTagName('head')[0];
>                 $Script = document.createElement('script');
>                 $Script.setAttribute('type', 'text/javascript');
>                 $Script.setAttribute('src', $sFile);
>                 $Head.appendChild($Script);
>         } else
>         {
>                 console.log("ERROR: Browser does not support dynamic element
> creation.")
>         }}
>
> Autoload.init = function()
> {
>         for($index in Autoload.aFiles)
>         {
>                 
> Autoload.includeScript("script/"+Autoload.aFiles[$index]+".js");
>         }
>         Background.init(); // Where error is
>
> }
>
> window.onload = Autoload.init();

--

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