How to create and modify a redirection drop-down list box in FrontPage 2002 (310713)



The information in this article applies to:

  • Microsoft FrontPage 2002

This article was previously published under Q310713
For a Microsoft Office FrontPage 2003 version of this article, see 825545.

SUMMARY

This article describes how to create and modify a drop-down list box control that opens a specific Uniform Resource Locator (URL) by using JavaScript. The procedures are performed in an existing FrontPage 2002 Web site.

NOTE: This article makes use of custom JavaScript that may not be available in all browsers. For more information about compatibility with other browsers, click Microsoft FrontPage Help on the Help menu, type compatibility in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

(back to top)

Creating the Redirection Drop-Down List

NOTE: You may receive an error message if you copy the examples directly from this article and paste them into FrontPage. The angle brackets (< and >) may appear as escaped HTML code (< and >). To work around this behavior, paste the script into a blank Notepad document, and then copy it from Notepad before you paste it into FrontPage.

NOTE: Because there are several versions of Microsoft Windows, the following steps may be different on your computer. If they are, see your product documentation to complete these steps.

  1. Start FrontPage. Open a Web. On the File menu, point to New, and then click Page or Web.
  2. In the New Page or Web task pane, click Blank page.
  3. Click the HTML tab at the bottom of the FrontPage window.
  4. Position the insertion point on a blank line just below the <BODY> tag where you want to place the JavaScript code.
  5. Minimize FrontPage.
  6. Use a copy and paste operation to add the following code sample to the Web page. To do this in Microsoft Internet Explorer, follow these steps:
    1. Select the following code sample:
      <h3 align="center">Where Do You Want to Go Today?</h3>
      <center>
      <form>
        <p><select name="section" size="1" language="javascript" onChange="gotoPage(this.selectedIndex);">
        <option selected>Where do you want to go today?</option>
        <option>- - - - - - - - - - - - - - - - -</option>
        <option>Microsoft Home Page</option>
        <option>MSN Home Page</option>
        </select></p>
      </form>
      </center>
      <script language="JavaScript">
      <!--
      function gotoPage(varItem)
      {
        switch(varItem)
        {
          case 0:
            window.parent.self.status="Goes Nowhere";
            break;
          case 1:
            window.parent.self.status="Goes Nowhere";
            break;
          case 2:
            window.location="http://www.microsoft.com";
            break;
          case 3:
            window.location="http://www.msn.com";
            break;
        }
      }
      // -->
      </script>
      						
    2. On the Edit menu, click Copy.
    3. Start Notepad. To do this, point to Programs on the Start menu, point to Accessories, and then click Notepad.
    4. In Notepad, click Paste on the Edit menu.
    5. On the Edit menu, click Select All.
    6. On the Edit menu, click Copy.
    7. Minimize Notepad and then switch to FrontPage.
    8. On the Edit menu, click Paste.
  7. On the File menu, click Save.
  8. Click the Preview tab at the bottom of the FrontPage window to view the redirection drop-down list box.
NOTE: This code sample uses the window.location property to load new pages. If you are using a frameset, the new page is displayed in the current frame. As an alternative, you can use the window.open() method to load the page and specify a target frame. For example, to display the Microsoft home page in a full screen, use the following JavaScript code:
    case 2:
      window.open("http://www.microsoft.com", target="_top");
      break;
				
(back to top)

Adding a URL to the Redirection Drop-Down List Box

To add a URL to the sample, make the following changes:
  • Add an entry to the options list in the HTML code.
  • Add an entry to the switch section in the JavaScript code.
For example, to add a menu choice for the MSNBC Web site, follow these steps.

NOTE: These instructions assume that you made no changes to the script after you pasted it into FrontPage.
  1. In FrontPage, click the HTML tab at the bottom of the FrontPage window.
  2. Click immediately after the following line
    <option>MSN Home Page</option>
    						
    and then press ENTER.
  3. Type the following HTML code
    <option>MSNBC Home Page</option>
    						
    to add this item to the list of menu choices.
  4. Locate the following section in the JavaScript code:
        case 3:
          window.location="http://www.msn.com";
          break;
    						
    Click immediately after break; and then press ENTER.
  5. On the blank line, type the following JavaScript code to redirect the URL to the new site you are adding:
        case 4:
          window.location="http://www.msnbc.com";
          break;
    					
  6. On the File menu, click Save.
  7. Click the Preview tab at the bottom of the FrontPage window to test the changes.
(back to top)

Removing a URL from the Drop-Down List Box

If you want to remove a URL from the sample code, you need to make the following changes:
  • Remove an entry from the options list in the HTML code.
  • Remove an entry from the switch section in the JavaScript code.
To remove the MSNBC Web site option from the list, follow these steps:
  1. Click the HTML tab at the bottom of the FrontPage window.
  2. Locate the following line of code:
    <option>MSNBC Home Page</option>
    					
  3. Select the entire line and then press DELETE.
  4. Locate the following section in the JavaScript code:
        case 4:
          window.location="http://www.msnbc.com";
          break;
    						
    Select these three lines of code and then press DELETE.
  5. On the File menu, click Save.
  6. Click the Preview tab at the bottom of the FrontPage window to test the changes.
NOTE: If you remove a menu item that is not the last choice, you also need to renumber the items. For example, if you remove the MSN Web site option from the list of choices, renumber the MSNBC choice so that it is the new case 3 item.

(back to top)

REFERENCES

For additional information about creating redirection drop-down list boxes, click the following article numbers to view the articles in the Microsoft Knowledge Base:

197959 How to use VBScript or JavaScript to create a drop-down control that opens a specific URL in FrontPage 2000

194091 FP98: How to redirect a browser from a list box choice

167594 FP: How to redirect a browser from a list box choice

(back to top)

Modification Type:MinorLast Reviewed:10/28/2004
Keywords:kbProgramming kbConfig kbnewfile kbHOWTOmaster KB310713 kbAudITPro