Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > JavaScript Question

JavaScript Question
Thread Tools
Jaey
Mac Elite
Join Date: Dec 2003
Status: Offline
Reply With Quote
May 18, 2004, 05:26 PM
 
I've been a bit out of the javascript mode for a while, but I was making a page and realized how much nicer it could be with that beautiful script I wrote back in the day. So I dug up the script, and tried it out. It really doesn't seem to work at all. This is the script
Code:
function stan(id){ if (document.all) { if(document.all[id].style.display=='none'){ document.all[id].style.display=''; } else { document.all[id].style.display='none'; } return false; } else if (document.getElementById){ if(document.getElementById(id).style.display=='none') { document.getElementById(id).style.display='block'; return false; } else { document.getElementById(id).style.display='none'; return false; } return false; } }
In safari and mozilla, the menu drops down, then pops back up, as if the return false;. In internet explorer, it doesn't work at all. Can someone tell me what's wrong with my script?
     
Chris O'Brien
Grizzled Veteran
Join Date: Nov 2003
Location: Hebburn, UK
Status: Offline
Reply With Quote
May 18, 2004, 05:41 PM
 
Not sure why you have all the return falses in there, but I haven't looked too closely at to what you're doing.
Off the top of my head, would this work? :

Code:
function stan(id) { var el; el = (document.all) ? document.all[id] : document.getElementById(id); with (el.style) { (display == "none") ? display = "" : display = "none"; } }
Probs not the best way - and as I say, it's off the top of my head in 30 seconds flat.

Back to revision pour moi.
Just who are Britain? What do they? Who is them? And why?

Formerly Black Book
     
Jaey  (op)
Mac Elite
Join Date: Dec 2003
Status: Offline
Reply With Quote
May 18, 2004, 06:26 PM
 
Originally posted by Black Book:
Not sure why you have all the return falses in there, but I haven't looked too closely at to what you're doing.
Off the top of my head, would this work? :

<snip>

Back to revision pour moi.
aight, I'll try that.
And sorry about the return falses, I was plugging them in randomly to see what would would happen.
     
DUNSEL
Forum Regular
Join Date: Feb 2004
Location: Manhattan
Status: Offline
Reply With Quote
May 18, 2004, 06:29 PM
 
Can I ask why the document.all test? IE has supported getElementById for every version since 4, I believe.
I saw a woman with a sweatshirt that said "Guess", so I said, "Implants?"
     
Chris O'Brien
Grizzled Veteran
Join Date: Nov 2003
Location: Hebburn, UK
Status: Offline
Reply With Quote
May 19, 2004, 01:33 AM
 
Version 5, yeah. I wondered about the document.all test too, but since Jaey's original script tested for it, I thought I'd put one in too... I'd be very surpried to hear of anyone using IE4, but who knows?
Just who are Britain? What do they? Who is them? And why?

Formerly Black Book
     
DUNSEL
Forum Regular
Join Date: Feb 2004
Location: Manhattan
Status: Offline
Reply With Quote
May 19, 2004, 06:43 PM
 
If someone out there is still using it, they deserve to suffer. I say, let em.
I saw a woman with a sweatshirt that said "Guess", so I said, "Implants?"
     
Chris O'Brien
Grizzled Veteran
Join Date: Nov 2003
Location: Hebburn, UK
Status: Offline
Reply With Quote
May 20, 2004, 08:22 AM
 
Originally posted by DUNSEL:
If someone out there is still using it, they deserve to suffer. I say, let em.
I say the same thing about Windows
Just who are Britain? What do they? Who is them? And why?

Formerly Black Book
     
   
Thread Tools
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 04:02 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,