|
-
Nov 26th, 2002, 06:12 AM
#1
Thread Starter
Don't Panic!
Javascript - IE - All....
Hi,
I have the following in html:
Code:
<span class="BArea"><span class="b1"><a href="#" onClick="SwitchMenu('TestMenu',document); return false;">A Link</a></span></span>
<div class="MenuArea" Name="TestMenu">
<span class="BArea"><span class="b1"><a href="#">Menu Link</a></span></span>
<span class="BArea"><span class="b1"><a href="#">Another Link</a></span></span>
</div>
I can't seem to reference the TestMenu tag/item at all using :
Code:
document.all.item(TestMenu).visibility = true;
Any ideas what I'm doing wrong?
Vince
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Nov 26th, 2002, 07:21 AM
#2
Frenzied Member
I don't think you need to use all (which is IE only by the way), you should just be able to do it like this:
document.TestMenu.style.visibility = 'visible';
Or if you want to use IDs:
<div id="elementId">
document.getElementById('elementId').style.visibility = 'visible';
-
Nov 26th, 2002, 10:06 AM
#3
Thread Starter
Don't Panic!
IE6
Hi Rick,
Thanks. Still didn't work tho 
I found in my Javascript book a chunk of code to print out the properties to a debug window. And I couldn't find style or visibility.
After a bit of experimentation:
function SwitchMenu (mnuName,d)
{
// listPropertyNames(mnuName.currentStyle);
debug('Class : ' + mnuName.currentStyle.visibility);
// debug(mnuName + ' ' + mnuName.innerHTML);
/* if (browser.isIE){
mnuName.style.visibility = !mnuName.style.visibility;
} else if (browser.isNN) {
}
*/
}
This seemed to print out what I needed.
So as a quick question -
Does this mean older browsers are different????
Vince
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Nov 26th, 2002, 11:03 AM
#4
Thread Starter
Don't Panic!
Just to let you know. The following appears to work properly in IE6... SP1....
Code:
function SwitchMenu (mnuName,d)
{
if (mnuName.currentStyle.visibility=='hidden')
{
mnuName.style.visibility="visible";
} else {
mnuName.style.visibility="hidden";
}
}
I have to use current style to view and style to set or it doesn't work.
Weird??
Vince
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Nov 27th, 2002, 06:12 AM
#5
Frenzied Member
Originally posted by Ecniv
So as a quick question -
Does this mean older browsers are different????
Most browsers have a different implementation of JavaScript, HTML, XML etc. but if you code to standards most times it will work the same in all the modern browsers. And usually if you can get things working in Mozilla it will work in all the other browsers too, esp for CSS.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|