![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||||
| |||||
|
|
I have found a show-hide script that is nice and short and seems easy to use. But, I dont know if it is cross-browser. |
|
I have just current version of MSIE, Netscape and Opera and it works in them. I do want to know if this works with other, especially the slightly older browsers. |
|
script type="text/javascript" !-- function ShowHide(id, visibility) { obj = document.getElementsByTagName("div"); obj[id].style.visibility = visibility; } //-- /script |
|
a href="javascript:ShowHide('sub1Div','visible')">sh ow.sub1</a> | |
|
Does anyone know what browsers this won't work in? |
#2
| |||
| |||
|
|
rfr said the following on 3/25/2006 12:29 AM: I have found a show-hide script that is nice and short and seems easy to use. But, I dont know if it is cross-browser. It isn't. I have just current version of MSIE, Netscape and Opera and it works in them. I do want to know if this works with other, especially the slightly older browsers. What qualifies as "slightly older"? 1 year? 5 years? 10 years? script type="text/javascript" !-- function ShowHide(id, visibility) { obj = document.getElementsByTagName("div"); obj[id].style.visibility = visibility; } //-- /script That looks like a dumb way to do this: function showHide(id,displayMode){ document.getElementById(id).style.visibility = displayMode; } But, do you know the difference between .style.visibility = "hidden" and .style.display = "none";? snip a href="javascript:ShowHide('sub1Div','visible')">sh ow.sub1</a> | URL: http://jibbering.com/faq/#FAQ4_24 Does anyone know what browsers this won't work in? It won't work in browsers that do not support the features you are trying to use. -- Randy comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/ |
#3
| |||
| |||
|
|
I am a cut-n-paste js script user seeking a show/hide script that is simple to impliment. This one loooks simple to use. Good. However, I know just enough to suspect that this works only with the browsers that use the new coding. If that is true, then this would fail on any browsers except those that use the new coding. Thus, I suspected that on browsers over 2 years old this scipt might fail. Bad. |
|
Can you point me to a show/hide js script that is BOTH simple to implement AND will handle recent browsers, say , . . since the major shift . . what was it . . since about NS 4? |
#4
| |||
| |||
|
|
rfr said the following on 3/25/2006 10:13 PM: I am a cut-n-paste js script user seeking a show/hide script that is simple to impliment. This one loooks simple to use. Good. However, I know just enough to suspect that this works only with the browsers that use the new coding. If that is true, then this would fail on any browsers except those that use the new coding. Thus, I suspected that on browsers over 2 years old this scipt might fail. Bad. Closer to browsers that are 5 years old or so. IE6 is ancient and it supports what your script does. Can you point me to a show/hide js script that is BOTH simple to implement AND will handle recent browsers, say , . . since the major shift . . what was it . . since about NS 4? The function I gave in my last reply: function showHide(id,displayMode){ document.getElementById(id).style.visibility = displayMode; } Will work in IE5.0+, NS6+, Opera7 for sure (not sure about O6) and most "current" MAC browsers. But, the use of href="javascript: is a bigger problem than the script is. -- Randy comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/ |
#5
| |||
| |||
|
|
What is the problem that you speak of with the use of href="javascript:? |
|
Is there a preferred method to evoke this function that works more reliably or more cross-browser than this? |
![]() |
| Thread Tools | |
| Display Modes | |
| |