|
|
JavaScript Question
|
|
|
|
Mac Elite
Join Date: Dec 2003
Status:
Offline
|
|
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?
|
|
|
|
|
|
|
|
|
Grizzled Veteran
Join Date: Nov 2003
Location: Hebburn, UK
Status:
Offline
|
|
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
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Dec 2003
Status:
Offline
|
|
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.
|
|
|
|
|
|
|
|
|
Forum Regular
Join Date: Feb 2004
Location: Manhattan
Status:
Offline
|
|
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?"
|
|
|
|
|
|
|
|
Grizzled Veteran
Join Date: Nov 2003
Location: Hebburn, UK
Status:
Offline
|
|
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
|
|
|
|
|
|
|
|
Forum Regular
Join Date: Feb 2004
Location: Manhattan
Status:
Offline
|
|
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?"
|
|
|
|
|
|
|
|
Grizzled Veteran
Join Date: Nov 2003
Location: Hebburn, UK
Status:
Offline
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|