how to use window.onload?
<p>I'm refactoring a website using MVC. What was a set of huge pages with javascript, php, html etc etc is becoming a series of controllers and views. I'm trying to do it in a modular way so views are split in 'modules' that I can reuse in other pages when needed</p>

<p>eg.
"view/searchform displays only one div with the searchform
"view/display_events displays a list of events
and so on.</p>

<p>One of the old pages was supposed to load a google map with a marker on it.</p>

<p>Amongst the rest of the code, I can identify the relevant bits as follows</p>

<pre><code>&lt;head&gt;
&lt;script src="http://maps.google.com/maps?file=api&amp;amp;v=2&amp;amp;key=blablabla" type="text/javascript"&gt;&lt;/script&gt;

&lt;script type="text/javascript"&gt;
//&lt;![CDATA[
function load() {
    if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
        var point = new GLatLng(&lt;?php echo ($info-&gt;lat &amp;&amp; $info-&gt;lng) ? $info-&gt;lat .",". $info-&gt;lng : "51.502759,-0.126171"; ?&gt;);
        map.setCenter(new GLatLng(&lt;?php echo ($info-&gt;lat &amp;&amp; $info-&gt;lng) ? $info-&gt;lat .",". $info-&gt;lng : "51.502759,-0.126171"; ?&gt;), 15);
        map.addControl(new GLargeMapControl());
        map.addControl(new GScaleControl());
        map.addOverlay(new GMarker(point));
        var marker = createMarker(point,GIcon(),"CIAO");
        map.addOverlay(marker);
    }
}
//]]&gt;
&lt;/script&gt;
&lt;/head&gt;
</code></pre>

<p>...then</p>

<pre><code>&lt;body onload="load()" onunload="GUnload()"&gt;
</code></pre>

<p>...and finally this div where the map should be displayed </p>

<pre><code>&lt;div id="map" style="width: 440px; height: 300px"&gt; &lt;/div&gt;
</code></pre>

<p>Don't know much about js, but my understanding is that </p>

<p>a) I have to include the scripts in the view module I'm writing (directly in the HTML? I would prefer to load a separate script) </p>

<p>b) I have to trigger that function using the equivalent of body onload... (obviously there's no body tag in my view. In my ignorance I've tried div onload=.... but didn't seem to be working :)</p>

<p>What do you suggest I do?
I've read about window.onload but don't know what's the correct syntax for that.</p>

<p>please keep in mind that other parts of the page include other js functions (eg, google adsense) that are called after the footer.</p>
