Connecting Tech Pros Worldwide Forums | Help | Site Map

Tree menu

vagos
Guest
 
Posts: n/a
#1: May 31 '06
I try to build a tree menu.

The idea is that the submenu is in a hidden absolute position table. By
clicking the folder.gif, the submenu table switces to visible - static,
so opens.
This helps me to put the tree anywhere in a page, and not in x,y position.

It works fine in IE but not in Netscape or Firefox.

Can someone please help me to fix ??

Here is the code :


<html>
<head>
</head>

<script language=javascript>

function viewsub(){
if (view.type == "off"){
view.type="on";
view.style.visibility="visible";
view.style.position="static";
} else {
view.type="off";
view.style.visibility="hidden";
view.style.position="absolute";
}

}

</script>

<body>
<table cellpadding=1 cellspacing=0 border=1>
<td><img src=folder.gif onclick=viewsub()>Open folder

<table border=0 cellpadding=1 cellspacing=0 id="view" type=off
width=95% style="visibility: hidden; position:absolute; left: 0; top: 0">
<td>Sub link</td>
</table>

</td></table>

</body>
</html>


Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a
#2: Jun 1 '06

re: Tree menu


vagos wrote:
[color=blue]
> [...]
> It works fine in IE but not in Netscape or Firefox.
>
> Can someone please help me to fix ??
>
> Here is the code :
>
>
> <html>
> <head>
> </head>
>
> <script language=javascript>
>
> function viewsub(){
> if (view.type == "off"){
> view.type="on";
> view.style.visibility="visible";
> view.style.position="static";
> } else {
> view.type="off";[/color]

Again, host objects should not be used as data containers
if this required the augmentation with new properties.

It is not necessary here anyway, one can test against the
value of the `visibility' or `display' property instead.
[color=blue]
> view.style.visibility="hidden";
> view.style.position="absolute";[/color]

Use `display' instead of `visibility' and `position'.
[color=blue]
> }
>
> }
>
> </script>
>
> <body>
> <table cellpadding=1 cellspacing=0 border=1>
> <td><img src=folder.gif onclick=viewsub()>Open folder
>
> <table border=0 cellpadding=1 cellspacing=0 id="view" type=off
> width=95% style="visibility: hidden; position:absolute; left: 0; top: 0">
> <td>Sub link</td>
> </table>
>
> </td></table>
>
> </body>
> </html>[/color]

<URL:http://validator.w3.org/>
<URL:http://jigsaw.w3.org/css-validator/>

And don't use tables; use lists.

A tree made out of a list:
<URL:http://javascripttoolbox.com/lib/mktree/>

A tree with dynamically created branches:
<URL:http://pointedears.de/ObjectInspector>
(look into the showProperties() method in objinsp.js;
a TreeView library based on this is under construction)


PointedEars
Closed Thread


Similar JavaScript / Ajax / DHTML bytes