Whoa, whoa!  The old Netscape 4.x document.layers DOM is not supported 
by Mozilla or Netscape 6, never has and never will be.  You must use the 
W3C DOM (http://www.w3.org/DOM/) instead.  See 
http://developer.netscape.com/evangelism/docs/articles/updating-dhtml-web-pages/ 
for a good introduction.




Sean wrote:
> Ok,
> 
> Now let's try it with a layer and see if it still works!
> 
> I get no errors from the concole and no output to the screen
> in Mozilla, but again this is ok in Netscape 4.7x.
> 
> If I'm doing something stupid please point it out!
> 
> Sean
> 
> <html>
>  <head>
>   <title>Layer Test</title>
>   <script language="JavaScript1.2">
> 
>   docText = '';
>   var CR = String.fromCharCode( 13 );
>   var depth = 0;
>   var docText = '<h1>Menu</h1>' + CR;
> 
>   function Node( name, data, url, pRef ) {
> 
>     this.name = name;
>     this.data = data;
>     this.url = url;
>     this.pRef = pRef;
>     this.kids = new Array();
>     this.add = addKid;
>     this.paint = paintNode;
>     this.toggle = toggleNode;
>     this.dump = dumpNode;
> 
>   };
> 
>   function addKid( p, k ) {
> 
>     var subscripts = new Array();
>     subscripts = p.split( ',' );
>     pRef = 'menu';
>     for ( var i in subscripts ) {
>       if ( subscripts[ i ] !='' ) {
>         pRef = pRef + '.kids[' + eval( subscripts[ i ] ) + ']';
>       };
>     };     
>     pRef = pRef + '.kids'; 
>     kids = eval( pRef ); 
>     var temp = new Array( ( kids.length + 1 ) ); 
>     if ( kids.length > 0 ) {
>       for ( var i in kids ) { 
>         temp[ i ] = kids[ i ];
>       };
>     };
>     temp[ kids.length ] = new Node( k, 1, k + '.html', pRef + '[' +
> kids.length + ']' );
>     eval( pRef + ' = temp' );
>     eval( k + ' = kids.length' );
> 
>   };
> 
>   function paintNode() {
>     docText = docText + '<br>';
>     if ( depth > 0 ) {
>       for ( i = 0; i < depth; i++ ) {
>         docText = docText + '&nbsp;&nbsp;';
>       };
>     };
> 
>     if ( this.kids.length != 0 ) {
>       docText = docText +  '<a href="JavaScript:' + this.pRef +
> '.toggle();rePaint();"><b>' + this.name + '</b></a>' + CR;
>     } else {
>       docText = docText +  '<a href="' + this.url + '">' + this.name +
> '</a>' + CR;
>     };
> 
>     if ( this.data > 0 ) {
>       depth = depth + 1;
>       for ( i in this.kids ) {
>         this.kids[ i ].paint();
>       };
>       depth = depth - 1;
>     };
>   };
> 
>   function toggleNode() {
>     this.data = ( ( this.data + 1 ) % 2 );
>   };
> 
>   function dumpNode() {
>     alert( 'name: ' + this.name + ' data: ' + this.data + ' url: ' +
> this.url + ' kids: ' + this.kids.length );
>     for ( i in this.kids ) {
>       this.kids[ i ].dump();
>     };
>   }; 
> 
>   // build the menu
>   menu = new Node( 'root', 1 , 'root' );
>   menu.add( '', 'Evaluation' );
>   menu.add( 'Evaluation', 'History' );
>   menu.add( 'Evaluation', 'Physical' );
>   menu.add( 'Evaluation', 'Laboratory' );
>   menu.add( 'Evaluation', 'Imaging' );
>   menu.add( 'Evaluation,Imaging', 'Radiology' );
>   menu.add( 'Evaluation,Imaging', 'Ultrasound' );
>   menu.add( 'Evaluation,Imaging', 'CT' );
>   menu.add( 'Evaluation,Imaging', 'MRI' );
>   menu.add( 'Evaluation,Imaging', 'Angiography' );
>   menu.add( '', "Therapy" ); 
> 
>   function rePaint() {
> 
>     docText = '';
>     // paint the menu
>     for ( i in menu.kids ) {
>       menu.kids[ i ].paint();
>     };
> 
>     if ( navigator.appName == "Netscape" ) {
>     
>       // write the page to the frame
>       with ( document.xmenu.document ) {
>         close();
>         open( "text/html", "replace" );
>         writeln( docText );
>         close();
>       };
>     };
>     if ( navigator.appName == "Microsoft Internet Explorer" ) {
>       xmenu.innerHTML = docText; 
>     };
>   }; 
> 
>   </script>
>  </head>
>  <body bgcolor=white onLoad="rePaint();">
>   <script language="JavaScript1.2">
> 
>    if ( navigator.appName == "Netscape" ) {
>      document.write( '<LAYER NAME="xmenu" LEFT=8 width=256
> BGCOLOR=white></LAYER>' );
>    };
> 
>    if ( navigator.appName == "Microsoft Internet Explorer" ) {
>      document.write( '<DIV ID="xmenu"></DIV>'); 
>    };
> 
>   </script>
>   
>  </body>
> </html>
> 


Reply via email to