Sorry, Rob, but that's not true. First, the jsapi loader is loaded with its own <script> tag.
This <script> tag executes completely before any subsequent <script> tag is run. The next <script> tag calls google.load() several times. Each of those calls ends up calling document.write() to write yet another <script> tag. When google.load() is called from a <script> tag, it uses document.write() to write another script tag. So the net effect is very much as if you'd used individual <script> tags to load all those JS libraries. The only difference is that those generated <script> tags appear *after* the end of the <script> tag where the google.load() calls are made. So any additional code inside that <script> tag - such as the registerOnLoadHandler() - runs before the generated <script> tags. The fact that Jake ran into the same problem after using explicit <script> tags for all the JS files bears this out. (BTW, shouldn't the URL to the jsapi file include a key= value with an API key, or is that no longer needed?) You *can* call google.load in the onload handler, but then it operates quite differently. Instead of writing a <script> tag, it loads the library asynchronously with a dynamic script element. Jake, do you realize that you're loading jQuery and jQuery UI *twice*, once with the initial google.load() calls we're talking about here, and a second time inside your BabyNews.init function? This can't be a good thing. Use the View JavaScript command in the Web Developer Toolbar in Firefox and you'll see them in there twice (use Collapse All to just see the filenames). Also, BabyNews.init() calls document.write() in your viglink code! You can't do that. BabyNews.init() is called as an onload handler - after the document has been completely written and closed - and it is too late to call document.write() at this point. If you want to call document.write(), you have to do it inside a <script> tag or in JS code that is run at the time the <script> tag is loaded - not a function that is called later. -Mike On Tue, May 4, 2010 at 4:00 PM, Rob Russell <[email protected]> wrote: > Try putting the lines > > > google.load("jqueryui", "1");google.load("jquery", "1"); > google.load('gdata', '2.x', {packages: ['analytics']}); > > inside the init function that you register with > > gadgets.util.registerOnLoadHandler(Babynews.init); > > Pretty sure it's possible for the google.load line to run before the script > at http://www.google.com/jsapi finishes executing. In this case the > variable "google" would be undefined. > > Rob Russell > Google Developer Relations > > > On Mon, May 3, 2010 at 10:57 AM, Michael Geary <[email protected]> wrote: > >> I don't know what's causing that error, but I do notice another problem: >> you're loading jQuery UI before jQuery. You need to load jQuery first, >> before UI or any other jQuery plugins. >> >> -Mike >> >> >> On Mon, May 3, 2010 at 12:24 AM, JakeP <[email protected]> wrote: >> >>> >>> I have a google gadget embedded in a google sites page. I tried >>> posting this to sites help forum, but no responses there. >>> >>> The problem is that when I load the page in IE (8 or 9) I get the >>> error - google is 'undefined' >>> >>> This is what is loaded into the iFrame for the gadget when the page >>> loads: >>> <SCRIPT onreadystatechange="google.loader.domReady()" defer >>> src="//:"><HTML><HEAD><TITLE></TITLE></SCRIPT> >>> >>> IE says that the google var is undefined at this point and stops. >>> >>> Does anyone know why IE is having trouble with loading? >>> >>> >>> >>> Here's the gadget XML: >>> >>> <?xml version="1.0" encoding="UTF-8" ?> >>> <Module> >>> <ModulePrefs >>> <Require feature="com.google.gadgets.analytics" /> >>> </ModulePrefs> >>> <Content type="html"><![CDATA[ >>> >>> <script src="http://www.google.com/jsapi" type="text/javascript"></ >>> script> >>> <script type="text/javascript"> >>> google.load("jqueryui", "1");google.load("jquery", "1"); >>> google.load('gdata', '2.x', {packages: ['analytics']}); >>> gadgets.util.registerOnLoadHandler(Babynews.init); >>> </script> >>> >>> < OTHER JS LIBRARIES > >>> >>> < HTML CONTENT > >>> >>> ]]> </Content> >>> >>> </Module> >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "iGoogle Developer Forum" group. >>> To post to this group, send email to [email protected] >>> . >>> To unsubscribe from this group, send email to >>> [email protected]<google-gadgets-api%[email protected]> >>> . >>> For more options, visit this group at >>> http://groups.google.com/group/Google-Gadgets-API?hl=en. >>> >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "iGoogle Developer Forum" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]<google-gadgets-api%[email protected]> >> . >> For more options, visit this group at >> http://groups.google.com/group/Google-Gadgets-API?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "iGoogle Developer Forum" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-gadgets-api%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/Google-Gadgets-API?hl=en. > -- You received this message because you are subscribed to the Google Groups "iGoogle Developer Forum" 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/Google-Gadgets-API?hl=en.
