nicholasjon.com :: a weblog

Hi. I'm Nick Olejniczak and this is where I write about technology, the web and other bits of general geekery. I'm a web developer who loves Ruby on Rails, web standards and personal publishing. Interested in working together? Get in touch.

 

IE JavaScript bug?

October 24, 2005 at 3:15pm

I was adding some JavaScript behaviors to a form when I stumbled across an error I couldn't get my brain around. All the code validated, Mozilla rendered everything appropriately, but IE choked every time I tried to target this one specific div by its (apparenly) unique id.

Turns out (after a surprisingly long period of time) that div really did have a unique id, but the string making up that id was also used as a name attribute in a form element occuring higher up the page. Mozilla properly used ids to walk the DOM, but it seems IE grabbed both name and id attributes to navigate the page.

At this point the only fix I can see is to not share names and ids across a page. I admit this typically isn't too difficult to handle — but it's not exactly expected either.

Perhaps this is a well-known problem in some circles, but as someone who's been away from JavaScript for a long time it sure was a puzzler. I've put together a sample page so that you can see what I'm talking about — feel free to let me know in the comments if I'm completely off my rocker and this behavior is somehow expected.

 

Unnecessary weather information at the time of posting

Weather data was not being recorded at this time.