Hi,

This looks to me like a DOM-readiness issue. The JS above the body tag
looks like it is writing to the DOM potentially before the body has
even started loading. When the body tag loads, it may be obliterating
the elements you added previously. My suggestions are either to:
1. Put all script tags inside the body
2. Wrap the topmost script tag in a document.onload event, or function
called by gadgets.util.registerOnLoadHandler

Dan

On Oct 1, 2:15 pm, ntuple <[email protected]> wrote:
> I'm having a problem consolidating my code in one place as images I
> define before the body are not recognized in it. This is making me
> write two scripts sections which I would like to avoid. Would
> appreciate any help.
>
> Here's my code:
>
> ********************************
> <Content type="html"><![CDATA[
> <script type="text/javascript">
>   var imgSrc='http://dev.xyz.edu/images/test/maps';
>   var linkSrc='http://www.xyz.edu/maps-';
>
>   var ran=Math.floor(Math.random()*20)+1;
>
>   var textArray  = new Array("London",
>                   "Paris",
>                   "Rome",
>                   "Tokyo",
>                   "Potato podimaas",
>                   "New York"
>                   );
>
>   var linkArray  = new Array("london",
>                   "paris",
>                   "rome",
>                   "tokyo",
>                   "new-york"
>                     )
>
>   //Setup links
>   imgSrc=imgSrc + (ran) + '.png'
>   linkSrc=linkSrc + linkArray[ran-1] + '.htm';
>
>   document.body.style.backgroundColor='660000'
>   document.body.style.color='f7fad6'
>
>   document.write("<br>")
>   document.write(textArray[ran-1])
>
>   function linkIt()
>   {
>     window.open(linkSrc);
>   }
> </script>
>
> <body>
> <a href="#" onclick="linkIt();return false">
> <img id="tourDay" width=200 height=160 /> </a>
> <script>
>   var tourImg = document.getElementById("tourDay");
>   tourImg.src = imgSrc;
> </script>
> </body>
>
> ]]></Content>
> </Module>
>
> ********************************
> Moving these two lines defining the image source out of the body gives
> me an "image is null" error.
>
>   var tourImg = document.getElementById("tourDay");
>   tourImg.src = imgSrc;
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to