- basic scripting -

       The Netscape Menu
.   .   .

This part is easy, because it's already done with Microsoft. So, just change the script to fit the Netscape mess, and you're all done. I've done the script to move it right in Netscape. (the new script is bolded).



<script language="JavaScript">
<!--

var m = (document.all);
var n = (document.layers);
var way = 0;

function go() {
               if (way == 0) { goRight(); }
               if (way == 1) { goLeft(); }
               }

function goRight() {
                    if (m) { 
                            menu1.style.left = parseInt(menu1.style.left) + 10;
                            if (parseInt(menu1.style.left) == 50) { way=1; return false; }
                            }
                    if (n) {
                            document.menu1.left += 10;
                            if (document.menu1.left == 50) { way=1; return false; }
                            }

                   setTimeout("goRight()",10);
                   }


function goLeft() {
                   if (m) { 
                           menu1.style.left = parseInt(menu1.style.left) - 10;
                           if (parseInt(menu1.style.left) == -210) { way=0; return false; }
                           }
                   setTimeout("goLeft()",10);
                   }

//-->
</script>

The script is getting longer, but it still should make sense. The line if (n) { says "If the browser is Netscape, then do this:" document.menu1.left += 10; That line moves the object to the right 10 pixels. The next line: if (document.menu1.left == 50) { way=1; return false; } This line stops the object when it gets to 50 pixels.

I'm going to go ahead and finish the script off: (the new script is bolded)



<script language="JavaScript">
<!--

var m = (document.all);
var n = (document.layers);
var way = 0;

function go() {
               if (way == 0) { goRight(); }
               if (way == 1) { goLeft(); }
               }

function goRight() {
                    if (m) { 
                            menu1.style.left = parseInt(menu1.style.left) + 10;
                            if (parseInt(menu1.style.left) == 50) { way=1; return false; }
                            }
                    if (n) {
                            document.menu1.left += 10;
                            if (document.menu1.left == 50) { way=1; return false; }
                            }

                   setTimeout("goRight()",10);
                   }


function goLeft() {
                   if (m) { 
                           menu1.style.left = parseInt(menu1.style.left) - 10;
                           if (parseInt(menu1.style.left) == -210) { way=0; return false; }
                           }
                     if (n) {
                            document.menu1.left -= 10;
                            if (document.menu1.left == -210) { way=0; return false; }
                            }
                   setTimeout("goLeft()",10);
                   }

//-->
</script>

Yes! The moving part is done, and the working script (for both browsers) is here.

next >>

.   .   .

  1. Introduction
  2. What, Exactly, is it?
  3. The [object]
  4. Detecting Browsers
  5. Accessing Properties
  6. Making a Script
  7. Making the Script in Netscape
  8. What to Change?
  9. Creating a Menu
  10. Scripting the Menu
  11. The Netscape Menu
  12. Last Words