You know, if you gave me the straight answer to my question it would actually be better for my understanding of what you're trying to tell me.
""initialize()" exists, so window.onload is happy. " That sort of obfuscated, I'm-giving-you-a-nudge-in-the-right-direction- so-you-can-figure-it-out-yourself answer is not helpful and is not going to make me a better Computer Scientist. Sometimes to get someone to understand the "why" you need to tell them the "what", straight & clear. This is one such case. / Vahagn On Jan 16, 4:33 pm, "warden [Andrew Leach - Maps API Guru]" <[email protected]> wrote: > On Jan 16, 3:20 pm, railscoder <[email protected]> wrote: > > > All right then, allow me the Next n00b Question: > > > How do I load this Google Maps API script with GUnload in it? I have > > this Maps recipe from a book and just applied it exactly as it was in > > the book (you know, great programmers don't write code but re-use it). > > Turns out the recipe is incomplete. > > > > The block of code defined as initialize() will never get run until and > > > unless it is asked for, in your case at the load event time by the > > > window.onload setting. > > > Yes, but when the thread executes the window.onload setting it IS > > being asked to execute initialize() - why doesn't it do that? > > Depends what you mean by "executes the window.onload setting". When > that line of code is reached and executed, it sets "window.onload" to > initialize(). That means that initialize() is set up to run when the > page load is completed. "initialize()" exists, so window.onload is > happy. That line of code doesn't actually cause initialize() to be > executed there and then: execution is triggered by the page load > completing. > > The next line of code sets window.onunload, and does the same thing; > it sets things up so that GUnload is executed when the page is exited. > GUnload doesn't exist at that point, so it fails. > > GUnload will only exist once the API script is loaded, so you need to > load application.js after that. > > Andrew > > Andrew --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Maps API" 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-Maps-API?hl=en -~----------~----~----~----~------~----~------~--~---
