View Single Post
Join Date: Jun 2008
Posts: 130
Reputation: Q8iEnG is an unknown quantity at this point 
Solved Threads: 2
Q8iEnG Q8iEnG is offline Offline
Junior Poster

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

 
0
  #5
Dec 2nd, 2008
Originally Posted by Luckychap View Post
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 ];
so you meant that the problem is from this code??

Ok, is it necessary to use that code?
  1. if(document.banner)
  2. document.banner.src = bannerRotate[ getNewBanner ];


please could anyone explain to me just why we used (document.banner.src)???
it is not defined I mean in my whole code there's no (banner) so where did it comes from? and how it works?

thanks in advance will be much more appreciated..
Last edited by Q8iEnG; Dec 2nd, 2008 at 5:51 am.
Reply With Quote