Javascript onclick event is not working in internet explorer 8.
Posted
by Mallika Iyer
on Stack Overflow
See other posts from Stack Overflow
or by Mallika Iyer
Published on 2010-04-20T19:54:54Z
Indexed on
2010/04/20
20:13 UTC
Read the original article
Hit count: 260
Hi, I have the following line of code that works fine in Firefox, Chrome and Safari, but not in internet explorer 8.
<a href="javascript:void(0);" onclick="showHide('reading','type_r','r');">Show me the example</a>
The function simply shows and hides a div on clicking the hyperlink.
Is there anything I'm missing here?
This is the showHide function:
function showHide(elementId,parentId,qtype) {
if (document.getElementById && !document.all) {
var elementParent = document.getElementById(parentId);
var element = document.getElementById(elementId);
var upArrowId = 'up-arrow-'+qtype;
var downArrowId = 'down-arrow-'+qtype;
if(element.style.visibility == 'hidden'){
elementParent.style.height = 'auto';
element.style.visibility = 'visible';
document.getElementById(upArrowId).style.visibility = 'visible';
document.getElementById(downArrowId).style.visibility = 'hidden';
}
else if(element.style.visibility == 'visible'){
element.style.visibility = 'hidden';
elementParent.style.height = '50px';
document.getElementById(upArrowId).style.visibility = 'hidden';
document.getElementById(downArrowId).style.visibility = 'visible';
}
}
}
Thanks.
© Stack Overflow or respective owner