Hi everybody,
this is in regard to the tutorial Tony has set up (http://www.csscreator.com/css-forum/ftopic526.html). I have a similar "hiding things" script on my webpage and it is working out alright, except for one little annoyance that is driving my up randon walls. At the beginning of every page load you will have to click two times on the link instead of one. Explain this to a customer...
-"So I have to press on this?"
-"Yes - twice."
-"Okay - twice"
-"Yeah - but only the first time."
-"What?"
-"When you open it, you press it twice, after that only once."
-"Okay - to open press twice, to close once; Got it."
-"No - only for the first time you open it. After that you only once. Until you reload..."
-"I think I'm confused..."
Aaaaanyway - so I plugged Tonies script into the web-page and it did the same thing, so I am wondering where the fault might lie. I've set up a testing page:
http://www.kiebitzberg.de/test5.htm
to illustrate the problem. This is tested on Opera, Firefox and Mozilla.
Any hints are very much appreaciated.
"Hiding Things" - Reloaded
Hi Napper,
It's to do with the first testing of the value of display.
If you test to see if the object is not hidden instead of hidden it should work on first click.
obj.style.display=(obj.style.display!='none') ? 'none' :' inline' ;
Hope that helps
"Hiding Things" - Reloaded
Perfect!!!! That was it! And I've been spending days trying to find a solution for this on the web...
Thanks, Tony!
Napper
"Hiding Things" - Reloaded
Napper, just as a point of reference you may want to check the html as you have a block level element nesting within an inline one which won't please the validator
Hugo.