Forum Moderators: open

Message Too Old, No Replies

Javascript toggle-able div not working in Firefox

         

catsinboots

7:41 pm on Apr 7, 2006 (gmt 0)



Hi,

I'm using a script that I got off the web. It uses JavaScript to toggle a div on and off. It works fine in IE but not in Firefox. Here is the script I'm using:

function toggle( targetId ) {
if ( document.getElementById ) {
target = document.getElementById( targetId );
if ( target.style.display == "none" ) {
target.style.display = "";
} else {
target.style.display = "none";
}
}
}

Does anyone know what the problem could be?

Thanks.

RonPK

8:46 pm on Apr 7, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



target.style.display = "";

Try setting display to a real value, like 'block' or 'inline'.

Welcome to WebmasterWorld, by the way!