Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Not working in IE? 1

Status
Not open for further replies.

tviman

Programmer
Jul 25, 2002
2,123
US
I use the following script to show or hide a div on a web page. Works great on everything but IE!!!

Code:
function showDiv(which) {
   var visibleDiv = document.getElementById(which);
   visibleDiv.style.display = "block";
}

function hideDiv(which){
	var visibleDiv = document.getElementById(which);
  visibleDiv.style.display = "none";
}

I call these functions with either an <a href> element or an onclick reference - but IE just doesn't display the hidden div element. (And I don't get any javascript errors in the Firefox error panel.)

What do I need to do to make it compatible for all browsers?

Thanks...
 
Unlikely due to the functions themselves.
 
Fair enough - when I use it in an href element, it's like this: <a href="javascript:showDiv(1);">Show</a> and with and onclick: onclick="javascript:showDiv(1);"

Oddly - I placed an alert statement as the first line of the function and it doesn't even show in IE - as if it's not even seeing the function. Could it be as simple as an IE setting?
 
If you assign id as numeric (id="1" as it is suggested), it may not be appropriate. id should start with underscore and alphabet on the safe-side. Maybe re-assign the id and try again?
 
tsuji...

That was the ticket - and a star for you! Now it works in IE, FF, NS, & Opera.

THANK YOU!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top