I’ve noticed something weird under Firefox and how it evaluates flow control statements…

Basically what I’ve noticed is that when I did

Javascript [Show Plain Code]:
  1. if(document.getElementById("someID") == null)
  2. {
  3.         // create new element with someID here
  4. }

and I’ve put this in a timer event, so it was called every 60sec.

So what happened? Firefox evaluated it as

Javascript [Show Plain Code]:
  1. if(document.getElementById("someID"))

Argh, completely the other way around I was expecting it !

Workaround?

Javascript [Show Plain Code]:
  1. if( (document.getElementById("someID") == null ) )
  2. {
  3.        // create new element with someID here
  4. }

God bless FireBug :)

Leave a Reply