Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use of Div ID not working!!

Status
Not open for further replies.

dwhalen

Programmer
Feb 22, 2002
105
CA
I am trying to show and hide navigation bars depending on which button the user mouses over. So on mouseover of a button a function like this is called:

function toggle_6(){

if (document.Foo6.visibility=="hide"){
clear_all_tabs(6);
document.Foo6.visibility="show";
}
}
I create and name all the navigation bars with <Div> like this: <DIV ID=&quot;Foo6&quot;> ---code goes here--- </Div>

However on mouseover the line document.Foo6.visibility==&quot;hide&quot;) throws an error saying:
document.Foo6.visibility is null or not an object
Code:0

This only happens in the latest browsers of Netscape (6.2) and IE. It does not occur in eailer versions of Netscape. The O/S that I am testing on is WinXP and Linux (Red Hat).

Does anybody know if there is another way of naming the navigation bars? What am I doing wrong?

Thanks


 
Internet Explorer 4+ method of accessing a DIV:
Code:
document.all.Foo6
Netscape 6 and Internet Explorer 5+ method:
Code:
document.getElementById(&quot;Foo6&quot;)
Netscape 4 method:
Code:
document.layers.Foo6
or
Code:
document.Foo6

A little note, Netscape 4 will give errors if your DIV is not relatively or absolutely positioned (style=&quot;position:absolute|relative&quot;). Netscape 4 will act very strangely if you attempt to change the content of a relatively positioned DIV or SPAN, so if you ever come across wanting to change its contents, make sure it's not relatively positioned.
Code:
- UNIMENT
 
Thanks for your reply, sorry I didn't write back sooner but, I had left for the weekend and didn't get to check until now. I was wondering where you got this info from because I looked in all the books I own and there was no info on it at all, is there any documentation on the net?


Thanks again
 
I'm not even sure anymore where I got all my information. Namely, I looked at the docs for Netscape and IE and tested a whole bunch of code on both. If I ever need to know something, I'll generally test some code that I think should work, and if all else fails, I'll search Google.

Netscape 4 docs:

Internet Explorer DHTML docs:


If I ever need to know something about the core, I look at Netscape's docs. If I need to know something about the DOM, I'll generally use a for...in loop to go through the object and print to the screen all its properties rather than look at the docs.
Code:
- UNIMENT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top