This article describes how to create and modify a drop-down list box control that opens a specific URL by using JavaScript.
For a Microsoft FrontPage 2002 version of this article,
see
310713.
Note: This article
uses custom JavaScript/JScript that may not be available
in all Web browsers. For more information about Web
browser compatibility, click
Microsoft FrontPage Help on the
Help menu, type
browser compatibility in the
Search for box, and then
click Start searching to
view the topics that are returned.
back to the top
To create the redirection drop-down list box, follow these steps:
<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>
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. If you want, you can use the window.open method to load the page and then 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;
Note You may receive an error message, or the page may not display correctly if you copy the examples directly from this article and paste them into FrontPage. The angle brackets (< and >) may appear as HTML code. To work around this behavior, first paste the code sample into a blank document in Notepad, and then copy the code sample from the document in Notepad to your page in FrontPage. To do so, follow these steps:
To add a URL to the list that is displayed in the drop-down list box, you must do both of the following:
For example, to add a list item for
the Microsoft Help and Support Web site, follow these
steps:
Note These steps assume that you did
not make any changes to the code sample after you pasted
it to FrontPage.
<option>MSN Home Page</option>
<option>Microsoft Help and Support Home Page</option>
case 3:
window.location="http://www.msn.com";
break;
case 4:
window.location="http://support.microsoft.com";
break;
To remove a URL from the list that is displayed in the drop-down list box, you must do both of the following:
For example, to remove the list item for the Microsoft Help and Support Web site, follow these steps:
<option>Microsoft Help and Support Home Page</option>
case 4:
window.location="http://support.microsoft.com";
break;
Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and the tools that are used to create and debug procedures.
Microsoft Knowledge Base Article - 825545