![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| ||||
| ||||
|
|
toggleT('divt1','s'); |
|
function toggleT(_w,_h) { if (document.all) { // is IE |
|
if (_h=='s') eval("document.all."+_w+".style.visibility='visibl e';"); |
|
if (_h=='h') eval("document.all."+_w+".style.visibility='hidden ';"); } else { // is NS? if (_h=='s') eval("document.layers['"+_w+"'].visibility='show';"); if (_h=='h') eval("document.layers['"+_w+"'].visibility='hide';"); } |
#4
| |||
| |||
|
|
try: function toggleT(_w,_h) { var xw = document.getElementById(_w) if (_h == 's') xw.style.visibility = 'visible'; else xw.style.visibility = 'hidden'; } or even shorter: function toggleT(_w,_h) { document.getElementById(_w).style.visibility = (_h == 's') ? 'visible' : 'hidden'; } not tested |
#5
| |||
| |||
|
|
I found the toggle function (shown below) and applied it to a form of mine. It works fine in IE, but in Firefox it appears to fail on the eval lines. |
|
toggleT('divt1','s'); function toggleT(_w,_h) { if (document.all) { // is IE if (_h=='s') eval("document.all."+_w+".style.visibility='visibl e';"); if (_h=='h') eval("document.all."+_w+".style.visibility='hidden ';"); } else { // is NS? if (_h=='s') eval("document.layers['"+_w+"'].visibility='show';"); if (_h=='h') eval("document.layers['"+_w+"'].visibility='hide';"); } |

#6
| |||
| |||
|
|
Evertjan. wrote: try: function toggleT(_w,_h) { var xw = document.getElementById(_w) if (_h == 's') xw.style.visibility = 'visible'; else xw.style.visibility = 'hidden'; } or even shorter: function toggleT(_w,_h) { document.getElementById(_w).style.visibility = (_h == 's') ? 'visible' : 'hidden'; } not tested Thanks for the prompt reply. I did some more poking around and ended up changing from visibility too display thus: document.getElementById(_w).style.display = 'block'; document.getElementById(_w).style.display = 'none'; Since these both seem to accomplish the same thing, I wonder what the difference is between the display and the visible properties and is one of them better than the other for this application? |
#7
| |||
| |||
|
|
Paul Lautman wrote on 02 mrt 2006 in comp.lang.javascript: toggleT('divt1','s'); function toggleT(_w,_h) { if (document.all) { // is IE IE and FF support support GetElementById and css !! [and most NS too, but are there any out there?] |

#8
| |||
| |||
|
|
visibility will just hide the element. the display property will remove it from the flow of the page entirely. Put this in a test page and view it: div>some text</div div style="display:none">Some other text</div div>This text will align right below the some text div</div div>some text</div div style="visibility:hidden">Some other text</div div>This text will not align right below the some text div</div The only difference in the two is one uses visibility, the other uses display |
![]() |
| Thread Tools | |
| Display Modes | |
| |