This is actually a bit OT for this discussion group since the question  
is just about how javascript works, but hopefully nobody minds if I  
take a stab at explaining. :)

If you have a <script></script> it will be executed as soon as the  
document has loaded to that point. So, if you have:
<script>
function foo() {
...
}
</script>
of course nothing will happen except that foo() will now be available  
to other scripts. On the other hand, if you have, say, some global  
variable, bar, then:
<script>
bar++;
</script>
bar will be immediately incremented as soon as that bit of code is  
loaded. Thus, if you add the following anywhere inside your <html></ 
html> tag:
<script>
window.onload = ...
window.onunload = ...
</script>
then the onload and onunload handlers will be set and called as  
appropriate. Of course replace "..." with references to your uniquely  
named functions.

Hopefully that was clear enough, and hopefully my wording wasn't so  
incorrect as to be useless. ;)

-G

On Feb 19, 2009, at 2:06 PM, newuser wrote:

>
> Thanks
>
> At the moment I have the initialize function at the bottom of the
> page.
>
> And the div halfway in the html.
>
> <div id="map_canvas" style="width: 500px; height: 300px"></div>
>
> How do I declare the onload="initialize()" onunload="GUnload()"
> outside the body tag.
>
> Where should the function initialize() be moved to?
>
> Thank you
>
>
> On Feb 19, 7:33 pm, "[email protected]" <[email protected]>
> wrote:
>> On Feb 19, 11:23 am, newuser <[email protected]> wrote:
>>
>>> Hello
>>
>>> I wondered if anyone could advise?
>>
>>> I am using Dreamweaver templates to construct the html layout of the
>>> website. I would like to add a google map to one of the pages.
>>
>>> The <body> tag is part of the template, so I cannot add the onload
>>> function to this tag.
>>
>>> Is there anywhere else I can place the onload="initialize()"
>>> onunload="GUnload()" code other than on the <body>
>>
>> Yes.
>>
>> anywhere on the page these work:
>> window.onloadhttp://javascript.about.com/library/blonload.htm
>> window.onunload
>>
>> But beware of previously existing values.
>>
>>   -- Larry
> >


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to