Javascript  -  Nav Menu (Frames)

In order to target a link from a drop-down menu, we need to create a JavaScript function which will take the information from the frame and then add a “target” to the body frame:

  • Right-Click (Control-Click if you’re on a Mac) in the Frame area and select “Frame HTML” (“Frame Script” if you’re using 2.0) or “Layout HTML” (if it’s the “Layout Area” frame) from the pop-up menu that appears.
     
  • In the “Between Head Tags” field (“Inside Head Tag” if you’re on 2.0), insert the following code:

    <script language="JavaScript">
    <!-- Hide the script from old browsers --
    function surfto(form) {
         var myindex=form.dest.selectedIndex
         window.open(form.dest.options[myindex].value,
         target="body");
    }
    // -->
    </script>



    (the break in the text above between “value,” and “target” is not a carriage return - put all of that on one continuous line)
  • Create a Layout Area, Text Area or Table and select the “... is a form” checkbox in the General tab of the Properties window.
     
  • Create a ComboBox form element in this form area.
     
  • Name the ComboBox form element dest
     
  • Populate this form element with the URLS for the pages you wish to link to from this menu. Keep in mind that if you’re using relative links, you must put in the path to the page relative to the page you’re placing the menu on (this can be tricky if you’re using “By Site Structure” as your File Structure setting)
    • If you’re using Version 3.0 or higher:
      Create a forms button in the forms area and set it to the button type “Button”.  Put “Go!” in as the text (or any other text you like), then add the following code to the “Object HTML” in the “Inside Element Tag” field:

      onClick = “surfto(this.form)”


       
    • If you’re using Version 2.0
      Create a text object and insert the following code into the “Before Element Tag” field of the “Element Script”:

      <input type=”button” value=”Go!” onClick = ”surfto(this.form)”>

... that should do it!

Go Back to Previous Page

Have a question that you can´t find the answer to? Want to report a possible bug?

Send a help request to NetObjects Technical Support