javascript - null pointer expection in IE and not in Firefox, why does this happen? -


i have script loops through array of html tag id's, elements in array empty. have if statement works fine in firefox throws null pointer or not object error in ie

if((storedvars.id) != ("")){selenium.browserbot.getcurrentwindow().document.getelementbyid(storedvars.id).type;}  

why fail in ie , not in firefox , proper syntax ie?

in ie might undefined or null rather empty string, try instead:

if(storedvars.id && storedvars.id !== "") 

(also bit more efficient due !== operator comparing 2 strings)


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -