View Single Post
Join Date: Aug 2006
Posts: 319
Reputation: Luckychap is on a distinguished road 
Solved Threads: 42
Luckychap's Avatar
Luckychap Luckychap is offline Offline
Posting Whiz

Re: Trying to change this JavaScript code, to work without External File..!! How?? plz

 
0
  #4
Dec 2nd, 2008
Your code is not working because for the first time when rotate is called document.banner is undefined. And setting properties to undefined objects (documet.banner.src = somthing) result in crash.

So when ever you want to set the property to any HTML element in javascript, first check that if it is defined yet or not and apply properties only when they are defined.

  1. if(document.banner)
  2. document.banner.src = bannerRotate[ getNewBanner ];
When you think you have done a lot, then be ready for YOUR downfall.
Reply With Quote