Posts Tagged ‘Javascript’

All of a sudden Firebug was showing a Javascript error when I clicked on an expanding panel in a page of my Rails app. This had been working for ages and I had done no changes in that area, so it was a bit of a puzzle. I had just upgraded Ubuntu (and Firefox along with it) though.

The error Firebug showed was:
An invalid or illegal string was specified"  code: "12 pointing to line 2844 in prototype.js

Line 2844 in prototype looked inoffensive enough:

results = $A(root.querySelectorAll(e)).map(Element.extend);

The offending line in the application’s javascript didn’t scream “problem” either:

elem.down('img').replace('<img src="/images/panels/active.gif" alt="hide section" />');

After a great deal of head-scratching from poring over the code, I turned to Google and eventually found this page:
perhaps javascript is not ready for xhtml 1.1 yet
The comment from Tobias revealed the issue – an all-numeric id attribute.
The div concerned had an id attribute set to 2009-12-16. Once I changed this to panel-control_2009-12-16 everything worked smoothly again.

I guess Firefox 3.5.x is stricter about these things than Firefox 3.0.x was.
Moral of the story and a mantra for my memorybanks: All id attributes should begin with a letter.


Read Full Post »