Posted by: khirakawa on: July 21, 2009
Are you getting an RJS error in IE6, that reads “[ Object Error ]“, followed by escaped javascript?
That’s what I was getting last night while I was creating some simple navigation tabs. It was frustrating because it worked in Firefox and Safari, but not IE6. And the error message? Object Error? What does that tell me? Nothing!
So I narrowed down my javascript code to this line:
var tab_1 = document.getElementById("first_tab");
tab_1.removeClassName("active");
This was throwing the error. But why?
Well, it turns out in order to use the Prototype method removeClassName(), the element (in this case, tab_1) must have Prototype DOM extensions.
So how do you get elements with Prototype DOM extensions? Use the dollar method my friend.
Instead of getting the element from getElementById() and then calling removeClassName(), simply do:
$("first_tab").removeClassName("active")
And voila, it works in Firefox, Safari, and IE6.