PDA

View Full Version : Javascript error in IE only



Harleyy
07-20-2011, 11:37 AM
Hello everyone,

I am using 2 scripts, one to call an accordion and one to call arrows for the corresponding.

Now i am trying to open this via an external link.
Here is the code that i am using it


<div style="width: 170px; padding-top: 5px; padding-bottom: 5px; cursor:pointer; color:#003399;" class="fontSmall">
<span onFocus="LocalTurnArrow(this,'Title01');">
<a href="#Title01" onclick="numberOne()">
<span onclick="LocalTurnArrow(this,'Title01')">Learn more</span></a></span></div>

It is working perfectly fine for all browsers, but in IE 8, its showing me an error, " object doesnt support this property or method " and i know the reson being the introduction of the <span onclick="LocalTurnArrow(this,'Title01')">Learn more</span>. As i had to use it to toggle the arrows.

The script where it is showing error in IE is below..

function turnArrow (what) {
$$('div#widget h3 span').removeClass('selected');
what.firstChild.className = 'selected';
}

and its pointing on character 2 i.e firstChild.
Any reasons as to why IE is behaving in this manner or am I wrong somewhere.

Awaiting replies.

Regards
Harleyy.

jscheuer1
07-20-2011, 01:08 PM
From what you show, that second span has no firstChild capable of a className. Other browsers are probably error correcting for this and ignoring it. IE apparently isn't. I'd just get rid of it.

If you want more help:

Please post a link to a page on your site that contains the problematic code so we can check it out.

Harleyy
07-22-2011, 07:14 AM
I just made a new function for that span and it worked in IE without errors or warnings.
Thanks a lot for your time and reply.