Microsoft KB Archive/825545

= How to create and modify a redirection drop-down list box in SharePoint Designer 2007 and in FrontPage 2003 =

Article ID: 825545

Article Last Modified on 1/24/2007

-

APPLIES TO


 * Microsoft Office SharePoint Designer 2007
 * Microsoft Office FrontPage 2003

-





For a Microsoft FrontPage 2002 version of this article, see 310713.



SUMMARY
This article describes how to create and modify a drop-down list box control that opens a specific URL by using JavaScript in Microsoft Office FrontPage 2003 and in Microsoft Office SharePoint Designer 2007.

Note This article uses custom JavaScript/JScript that may not be available in all Web browsers.



Create the redirection drop-down list box
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is 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 with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure. However, they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

To create the redirection drop-down list box, follow these steps:  Start SharePoint Designer 2007 or FrontPage 2003, and then open your site. In SharePoint Designer 2007, click the New Document button on the toolbar.

In FrontPage 2003, click the New Page button on the toolbar. On the View menu, click Page if it is not already selected, and then click Code at the bottom of the page.  Insert the following code sample between the tag and the tag on your page: Where Do You Want to Go Today?  Where do you want to go today? - - - - - - - - - - - - - - - - -  Microsoft Home Page MSN Home Page 

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(&quot;http://www.microsoft.com&quot;, target=&quot;_top&quot;); 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 SharePoint Designer 2007 or into FrontPage 2003. The angle brackets 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 SharePoint Designer 2007 or in FrontPage 2003. To do this, follow these steps:  Copy the code sample from step 4.</li> Start Notepad, and then open a blank document.</li> On the Edit menu, click Paste.</li> On the Edit menu, click Select All.</li> On the Edit menu, click Copy.</li> In SharePoint Designer 2007 or in FrontPage 2003, position the insertion point on a blank line immediately below the tag where you want to insert the JavaScript code.</li> On the Edit menu, click Paste.</li></ol> </li> On the File menu, click Save.</li> In the Save As dialog box, specify a file name and a location where you want to save the page, and then click Save.</li> On the File menu, point to Preview in Browser, and then click the Web browser that you want to use to preview the page.</li></ol>

Add a URL to the redirection drop-down list box
To add a URL to the list that is displayed in the drop-down list box, you must do both of the following:
 * Add an entry to the option list in the HTML code.
 * Add an entry to the &quot;switch(varItem)&quot; section in the JavaScript code.

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 into SharePoint Designer 2007 or into FrontPage 2003. <ol> Start SharePoint Designer 2007 or FrontPage 2003 if it is not already started, and then open the page that contains the drop-down list box.</li> On the View menu, click Page if it is not already selected, and then click Code at the bottom of the page.</li> Position the insertion point immediately after the following HTML code on your page, and then press ENTER to create a new line:

MSN Home Page

</li> On the new line, type the following HTML code to add this item to the list:

Microsoft Help and Support Home Page

</li>  Position the insertion point immediately after the following JavaScript code on your page, and then press ENTER to create a new line: case 3: window.location=&quot;http://www.msn.com&quot;; break; </li>  On the new line, type the following JavaScript code to redirect the URL to the Web site that you are adding: case 4: window.location=&quot;http://support.microsoft.com&quot;; break;                   </li> <li>On the File menu, click Save.</li> <li>On the File menu, point to Preview in Browser, and then click the Web browser that you want to use to preview the page.</li></ol>

Remove a URL from the drop-down list box
To remove a URL from the list that is displayed in the drop-down list box, you must do both of the following:
 * Remove the entry from the option list in the HTML code.
 * Remove the entry from the &quot;switch(varItem)&quot; section in the JavaScript code.

For example, to remove the list item for the Microsoft Help and Support Web site, follow these steps: <ol> <li>Start SharePoint Designer 2007 or FrontPage 2003 if it is not already started, and then open the page that contains the drop-down list box.</li> <li>On the View menu, click Page if it is not already selected, and then click Code at the bottom of the page.</li> <li> Locate the following code: Microsoft Help and Support Home Page </li> <li>Select the code that you located in step 3, right-click the code, and then click Delete.</li> <li> Locate the following code: case 4: window.location=&quot;http://support.microsoft.com&quot;; break; </li> <li>Select the code that you located in step 5, right-click the code, and then click Delete.</li> <li>On the File menu, click Save.</li> <li>On the File menu, point to Preview in Browser, and then click the Web browser that you want to use to preview the page.</li></ol>

<div class="references_section">