donaddon is right, your code doesn't work because the script hasn't loaded yet. When you inject a script tag into the DOM, it's loaded asynchronously by design. This is a common trick used by web designers when they're trying to get script to load asynchronously when it otherwise wouldn't.
Erik On Sat, Dec 5, 2009 at 3:07 PM, donaddon <don...@verizon.net> wrote: > 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 <star...@gmail.com> 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 chromium-extensi...@googlegroups.com. > To unsubscribe from this group, send email to > chromium-extensions+unsubscr...@googlegroups.com<chromium-extensions%2bunsubscr...@googlegroups.com> > . > 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 chromium-extensi...@googlegroups.com. To unsubscribe from this group, send email to chromium-extensions+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/chromium-extensions?hl=en.