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
Post a Comment