<script type="text/javascript">
    aLabe = document.getElementById('alabel') ;
    function init(){
         aLabe.innerHTML= "asdf" ;
<body onload="init()">
<div id="container">
    <div id="header" > Google maps Intro 1</div>
    <div id="alabel">Yo!!</div>
    <div id="map_canvas"></div>

In the above,line 4 throws an aLabe is null error. Why is this? isn't aLabe a global var which is called before init()? If so then why doesn't init have access to aLabe ?

What you are doing is, before the page is done loading, you are looking for a control called alabel. Because the page is not done loading (the control has not been rendered), it can not find the control. So now aLabe is null.

You either want to put line 3 inside the init function or put the script at the end of the page (just before the closing body tag).

Oh! so its not that the aLabe isn't available inside the function , its just that the var aLabe is null, because its being called before our div#label exists on the page. Thanks much for clearing this up for me.