<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Lisa Wollin : JavaScript</title><link>http://blogs.msdn.com/lisawoll/archive/tags/JavaScript/default.aspx</link><description>Tags: JavaScript</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Creating a JavaScript Drop-Down Menu in FrontPage </title><link>http://blogs.msdn.com/lisawoll/archive/2004/12/16/323145.aspx</link><pubDate>Fri, 17 Dec 2004 02:16:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:323145</guid><dc:creator>lisawoll</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/lisawoll/comments/323145.aspx</comments><wfw:commentRss>http://blogs.msdn.com/lisawoll/commentrss.aspx?PostID=323145</wfw:commentRss><description>&lt;p&gt;We posted a new article on MSDN about &lt;a href="http://msdn.microsoft.com/office/understanding/frontpage/default.aspx?pull=/library/en-us/odc_fp2003_ta/html/officefrontpagecreatedropdownmenu.asp"&gt;creating JavaScript drop-down menus&lt;/a&gt;. If you read &lt;A href="http://blogs.msdn.com/lisawoll/archive/2004/10/05/238395.aspx"&gt;my earlier post about creating a drop-down menu&lt;/a&gt;, you may be interested in this article. The article uses a somewhat different method to show and hide menus than the code I showed earlier and also provides an example for cascading menus as well as menus that use image mouseovers.&amp;nbsp;Plus, at the end of the article, you will find several links where you can find additional methods for creating drop-down menus.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=323145" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/lisawoll/archive/tags/Articles/default.aspx">Articles</category><category domain="http://blogs.msdn.com/lisawoll/archive/tags/JavaScript/default.aspx">JavaScript</category></item><item><title>Creating Image Mouseovers</title><link>http://blogs.msdn.com/lisawoll/archive/2004/12/10/279773.aspx</link><pubDate>Sat, 11 Dec 2004 00:35:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:279773</guid><dc:creator>lisawoll</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/lisawoll/comments/279773.aspx</comments><wfw:commentRss>http://blogs.msdn.com/lisawoll/commentrss.aspx?PostID=279773</wfw:commentRss><description>&lt;p&gt;After I learned JavaScript, the first thing I did was create an image mouseover.&amp;nbsp;The one I created was relatively simple, just a few lines of code. I've since seen many more complex examples that do basically the same thing as my simple little script.&amp;nbsp;I'm not sure whether complex is better...although the complex examples do have two debatable benefits for the developers: one, making them hard to read (and thus hard to steal and modify); and two, making me feel incredibly stupid. Hmm. I definitely prefer simplicity.&lt;/p&gt; &lt;p&gt;The script that I made way back then was a simple one-function script that I called in both the onmouseover and onmouseout events.&amp;nbsp;The function took one parameter, which was a reference to the IMG element.&amp;nbsp;All I did was swap the image displayed for a new image by changing the src property.&amp;nbsp;Simple. Except that it didn't work in Netscape Navigator.&amp;nbsp;I never understood why, I just rewrote it.&lt;/p&gt; &lt;p&gt;I promised to provide an image mouseover script a few posts ago, so in today's post I'm providing a very simple mouseover script that you can use in your Web pages. This script is only slightly more complex than the one I first wrote, but it does the trick in a single function and only a few lines of code. This script works in Internet Explorer, Netscape Navigator, Mozilla, and Opera, and there doesn't appear to be any difference in the way the script functions in each browser.&lt;/p&gt; &lt;p&gt;The script makes a few assumptions that you will need to understand. It assumes that the filename for the normal, onmouseout image ends with &amp;quot;Off.gif,&amp;quot; and the active, onmouseover image ends with &amp;quot;On.gif.&amp;quot;&amp;nbsp;It also assumes that the images are stored in a folder named &amp;quot;graphics&amp;quot; that lives in the folder in which the page is stored. Your file structure and image-naming convention may be a bit different, so let me show you the script and explain it.&lt;/p&gt; &lt;pre&gt;function mouseoverImage(image)&lt;br /&gt; {&lt;br /&gt; var s = image.id;&lt;br /&gt; var ssrc = image.src;&lt;br /&gt; &lt;br /&gt; if (ssrc.match(/[Oo]ff/))&lt;br /&gt; {&lt;br /&gt; image.src = "graphics/" + s + "on.gif"&lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt; image.src = "graphics/" + s + "off.gif"&lt;br /&gt; }&lt;br /&gt; }&lt;/pre&gt; &lt;p&gt;The script uses a regular expression to determine whether the string &amp;quot;off&amp;quot; exists in the filename (or the value of the src attribute of the IMG element passed by using the image argument). (If you are unfamiliar with regular expressions, see the article &lt;a href="http://office.microsoft.com/en-us/assistance/HP030923241033.aspx"&gt;Regular expressions&lt;/a&gt; on Office Online).&amp;nbsp;If the string exists, the script changes the image's src attribute to the &amp;quot;On&amp;quot; image, and if it doesn't exist, the script changes the src attribute to the &amp;quot;Off&amp;quot; image.&lt;/p&gt; &lt;p&gt;Here's the HTML that accompanies this script.&lt;/p&gt; &lt;pre&gt;&amp;lt;img src=&amp;quot;graphics/ImageOff.gif&amp;quot; id=&amp;quot;image&amp;quot; &lt;br /&gt; onmouseover=&amp;quot;javascript:mouseoverImage(this)&amp;quot; &lt;br /&gt; onmouseout=&amp;quot;javascript:mouseoverImage(this)&amp;quot;&amp;gt;&lt;/pre&gt; &lt;p&gt;This code assumes that you have two images: one named &amp;quot;imageOff.gif&amp;quot; and one named &amp;quot;imageOn.gif.&amp;quot; You should be able to easily modify the filenaming for your own images; however, your images should have a base string that is the same.&lt;/p&gt; &lt;p&gt;For example, you might want to use mouseover images with a menu. If the text for a menu item was &amp;quot;products,&amp;quot; your images might be named &amp;quot;productsOff.gif&amp;quot; and &amp;quot;productsOn.gif&amp;quot;; or the normal image might be &amp;quot;products.gif&amp;quot; and the mouseover image &amp;quot;productsOn.gif&amp;quot; or &amp;quot;productsOver.gif.&amp;quot;&lt;/p&gt; &lt;p&gt;There are a number of possible combinations, but my point is that they both have a base string of &amp;quot;products.&amp;quot;&amp;nbsp;So you would set the image's id attribute to the base, the src attribute to the normal, onmouseout image, and then set the script calls in the onmouseover and onmouseout events. If your images are named differently, you need to make a few modifications to the script as well.&lt;/p&gt; &lt;p&gt;The regular expression &amp;quot;[Oo]ff&amp;quot; locates the occurrence of &amp;quot;Off&amp;quot; or &amp;quot;off&amp;quot; in the filename.&amp;nbsp;If neither your normal nor your active image contains either string, the script won't function unless you change the regular expression. About the only thing that would complete this script is a script that preloads the images.&amp;nbsp;You can find numerous such scripts online, and FrontPage comes with a preload script.&amp;nbsp;I'll cover preloading images in a future post for those who may not understand why this is important.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=279773" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/lisawoll/archive/tags/Tips+and+Tricks/default.aspx">Tips and Tricks</category><category domain="http://blogs.msdn.com/lisawoll/archive/tags/JavaScript/default.aspx">JavaScript</category></item><item><title>Creating a scrolling marquee</title><link>http://blogs.msdn.com/lisawoll/archive/2004/12/02/274014.aspx</link><pubDate>Thu, 02 Dec 2004 23:30:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:274014</guid><dc:creator>lisawoll</dc:creator><slash:comments>15</slash:comments><comments>http://blogs.msdn.com/lisawoll/comments/274014.aspx</comments><wfw:commentRss>http://blogs.msdn.com/lisawoll/commentrss.aspx?PostID=274014</wfw:commentRss><description>&lt;p&gt;In FrontPage, you can create a scrolling marquee by clicking &lt;b&gt;Insert&lt;/b&gt; and &lt;b&gt;Web Component&lt;/b&gt;. (You can find it listed under Dynamic Effects.)&amp;nbsp; However, sometimes it's greyed out. This is because FrontPage inserts a MARQUEE element, which is only viewable from Internet Explorer. (Opera also displays the MARQUEE element properly.) To be able to add a marquee to your page, you need to specify that you are creating a page to be viewed only with Internet Explorer. You can do this from the &lt;b&gt;Authoring&lt;/b&gt; tab of the &lt;b&gt;Page Options&lt;/b&gt; dialog box (&lt;b&gt;Tools&lt;/b&gt; menu). Under &lt;b&gt;Browsers&lt;/b&gt;, select &lt;i&gt;Microsoft Internet Explorer Only&lt;/i&gt;.&lt;/p&gt; &lt;p&gt;Now that you know how to add a scrolling marquee, you may want to customize it. By default, FrontPage doesn't set any attributes when it inserts a marquee, so what you get is plain text that scrolls from right to left across the page. FrontPage provides a dialog box that allows you to change the direction (left or right), speed, behavior, size, and background color and specify whether the marquee repeats and how many times. This may provide all the functionality you want for your marquee, but what if you want to bold some text or add an image? Or what if you want the marquee to scroll from top to bottom or vice versa? One customer who contacted me wanted to make each letter a different color. Another customer wanted to add a hyperlink.&lt;/p&gt; &lt;p&gt;&lt;b&gt;Customizing a Marquee&lt;/b&gt;&lt;/p&gt; &lt;p&gt;To add customizations that FrontPage doesn't allow in the dialog box, you need to modify the HTML code in &lt;b&gt;Code&lt;/b&gt; view.&amp;nbsp; You can add almost any element you want to a marquee, and it will work perfectly fine. However, keep in mind that when you do this, the display in FrontPage will be ... uh ... funky.&amp;nbsp; The MARQUEE element is one of the few HTML elements that FrontPage does not display exactly WYSIWYG.&amp;nbsp; Instead, you see all the code that you add within the opening and closing &amp;lt;marquee&amp;gt; tags. FrontPage sees these as text, but the browser does not.&lt;/p&gt; &lt;p&gt;For example, perhaps you want to add a hyperlink to some text.&amp;nbsp; You can switch to &lt;b&gt;Code&lt;/b&gt; view and insert the hyperlink by adding an A element to the code (note that using the &lt;b&gt;Hyperlink&lt;/b&gt; dialog box will add a hyperlink around the entire marquee and not just around selected text).&amp;nbsp; To illustrate, I created a simple marquee and inserted a hyperlink around a portion of the text.&amp;nbsp; In &lt;b&gt;Design&lt;/b&gt; view, my marquee appears as shown in the following screen shot.&lt;/p&gt; &lt;p&gt;&lt;img src="http://www.wollinweb.com/blogimages/marquee1.gif" /&gt;&lt;/p&gt; &lt;p&gt;But in the browser, it scrolls as expected with hyperlinked text.&lt;/p&gt; &lt;p&gt;So now that you understand that what you see in FrontPage won't be exactly correct, you can add any number of other HTML elements to a MARQUEE element.&amp;nbsp; You can add P elements to create paragraphs; IMG elements to insert pictures; UL, OL, and LI elements to create numbered and bulleted lists; SPAN elements to change the color and font of one or more characters; B elements, I elements, U elements, DIV elements, etc.&amp;nbsp; (You can even add MARQUEE elements, which gives you overlapping scrolling marquees. This may sound kinda cool but it would be very strange if not done exactly right&amp;nbsp;— for example, a top to bottom scrolling marquee that contains a right to left scrolling marquee might be a bit interesting....)&lt;/p&gt; &lt;p&gt;&lt;b&gt;Vertical Scrolling Marquee&lt;/b&gt;&lt;/p&gt; &lt;p&gt;In the &lt;b&gt;Marquee Properties&lt;/b&gt; dialog box, FrontPage provides the ability to change the direction of the scroll from left to right or right to left (the default is right to left). However, the MARQUEE element allows for scrolling from top to bottom and bottom to top as well. After you insert the marquee into your page, switch to Code view and change the direction attribute of the MARQUEE element to "up" to scroll from bottom to top or "down" to scroll from top to bottom.&lt;/p&gt; &lt;p&gt;&lt;b&gt;Scripting the MARQUEE element&lt;/b&gt;&lt;/p&gt; &lt;p&gt;There are a variety of things that you can do to change the appearance of scrolling marquees, but one I saw recently was someone who wanted the marquee to slow down upon mouseover.&amp;nbsp; As long as browser compatibility isn't an issue, since this only works in IE, you can script the MARQUEE element to slow down on mouseover, and then to speed up on mouseout.&lt;/p&gt; &lt;p&gt;The following two functions, slow and fast, change the scroll speed (by changing the scrollAmount property) of a specified MARQUEE element.&lt;/p&gt;&lt;pre&gt;&amp;lt;script language="javascript"&amp;gt;&lt;br /&gt; function slow(ele)&lt;br /&gt; {&lt;br /&gt; ele.scrollAmount = 1;&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; function fast(ele)&lt;br /&gt; {&lt;br /&gt; ele.scrollAmount = 15;&lt;br /&gt; }&lt;br /&gt; &amp;lt;/script&amp;gt;&lt;/pre&gt; &lt;p&gt;All you need to do to see this in action is to add the following HTML code to a page and display th page in IE.&lt;/p&gt; &lt;pre&gt;&amp;lt;marquee direction="up" width="238" height="100%"&lt;br /&gt; scrollamount="15" onmouseout="javascript:fast(this);"&lt;br /&gt; onmouseover="javascript:slow(this);"&amp;gt;This is a test.&amp;lt;/marquee&amp;gt;&lt;/pre&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=274014" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/lisawoll/archive/tags/Tips+and+Tricks/default.aspx">Tips and Tricks</category><category domain="http://blogs.msdn.com/lisawoll/archive/tags/JavaScript/default.aspx">JavaScript</category></item><item><title>Creating Mouseover Effects</title><link>http://blogs.msdn.com/lisawoll/archive/2004/10/27/248763.aspx</link><pubDate>Wed, 27 Oct 2004 21:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:248763</guid><dc:creator>lisawoll</dc:creator><slash:comments>26</slash:comments><comments>http://blogs.msdn.com/lisawoll/comments/248763.aspx</comments><wfw:commentRss>http://blogs.msdn.com/lisawoll/commentrss.aspx?PostID=248763</wfw:commentRss><description>&lt;p&gt;I know, it's been awhile since I've posted a tip. A couple weeks ago I was in SQL Server training, and last week was taken up with catching up on everything I postponed during training.&amp;nbsp; Now I'm back and my tip for today is creating mouseover effects.&lt;/p&gt; &lt;p&gt;We get frequent questions about how to create mouseover effects, but there are a variety of different mouseover effects, and the scripts that accomplish them are very varied.&amp;nbsp; The tip I'm sharing today is a script that I created for selling a house.&amp;nbsp; The page shows a house plan; the house plan image contains image maps that when a user runs their mouse over, displays an image of the room next to the house plan.&amp;nbsp; Take a look at the &lt;a href="http://www.wollinweb.com/BlogImages/house.htm" target="_blank"&gt;finished page&lt;/a&gt; so that you can understand the type of mouseover I'm talking about here.&lt;/p&gt; &lt;p&gt;Creating this type of mouseover is relatively easy.&amp;nbsp; You have two main images on the page: one is the image that the user mouses over, the other is the image that changes upon mouseover. In this particular example, the house plans image is the first image.&amp;nbsp; I mapped the image (or created hot spots) to section it into rooms; each one of the rooms has an AREA element with an &lt;b&gt;href&lt;/b&gt; attribute value that contains the path and filename of the image to show on click, plus an &lt;b&gt;onmouseover&lt;/b&gt; event to show the image in a second image on the page.&amp;nbsp; (You can easily create an image map in FrontPage -- see &lt;a href="http://office.microsoft.com/en-us/assistance/HP052611731033.aspx" target="_blank"&gt;Add a hot spot to a graphic&lt;/a&gt; -- so don't worry about trying to create an image map by hand; however, you will need to add the &lt;b&gt;onmouseover&lt;/b&gt; event to each AREA element by hand.)&lt;/p&gt; &lt;p&gt;Okay, maybe that sounds confusing, so let me make it a bit easier.&amp;nbsp; If you've taken a look at the page, you see an image of the house plans on the left side of the page and on the right you see a picture of the front of the house.&amp;nbsp; The house plans image is the first image (as I mentioned above). The picture of the front of the house, the second image, is actually a container image.&amp;nbsp; When the page first displays, it shows the front of the house, but as the user drags the mouse pointer over the house plans, the picture of the front of the house changes to show a picture of the room over which the mouse pointer sit.&amp;nbsp; (Depending on the speed of your connection, you may need to wait a few seconds for the image to download.)&lt;/p&gt; &lt;p&gt;The script that makes this happen is all of two lines. To make it easy for you, I've included the function below.&lt;/p&gt;&lt;pre&gt;&lt;code&gt;function ShowPic(sImage)&lt;br /&gt; {&lt;br /&gt; sImage = "images/" + sImage + ".jpg";&lt;br /&gt; document.ShowRoom.src = sImage;&lt;br /&gt; }&lt;/code&gt;&lt;/pre&gt; &lt;p&gt;The script by it self does nothing spectacular.&amp;nbsp; The ShowPic function takes a string (sImage), which is the name of the image file to display on mouseover.&amp;nbsp; The script then uses the string (sImage) to concatenate a new string that contains the path to the image file ("images/") with the passed in value (sImage parameter) and the image extension (which in this case is ".jpg").&amp;nbsp; Then the code uses the &lt;b&gt;src&lt;/b&gt; property to change the &lt;b&gt;src&lt;/b&gt; attribute of the second image (which I gave a name attribute of "ShowRoom") to the value of the sImage string.&lt;/p&gt; &lt;p&gt;BTW, the script won't work without an image named "ShowRoom".&amp;nbsp; You can either create an image named "ShowRoom" or change the ShowRoom in the line document.ShowRoom.src to the name of the IMG element that acts as your container image.&lt;/p&gt; &lt;p&gt;For my page, I used an image map, but you don't have to use a map.&amp;nbsp; For example, you could have a vertical menu bar that on mouseover changes a central image on the page to a different image.&amp;nbsp; In this case, the ShowRoom image container becomes your central image, and each of the elements in the menu bar (which could be IMG or A elements depending on how your menu bar is setup) contains the &lt;b&gt;onmouseover&lt;/b&gt; event with the script call.&lt;/p&gt; &lt;p&gt;In the page you viewed above, I put in styles, so to make it easier to see what's going on in the code, here's some HTML to accomplish a mouseover effect without styles and without an image map.&amp;nbsp; In this example, I use A elements instead of AREA elements; otherwise, the effect is the same.&lt;/p&gt;&lt;pre&gt;&lt;code&gt;&amp;lt;html&amp;gt;&lt;br /&gt; &amp;lt;head&amp;gt;&lt;br /&gt; &amp;lt;title&amp;gt;House For Sale&amp;lt;/title&amp;gt;&lt;br /&gt; &amp;lt;script language="javascript"&amp;gt;&lt;br /&gt; function ShowPic(sImage)&lt;br /&gt; {&lt;br /&gt; sImage = "http://www.wollinweb.com/blogimages/images/" + sImage + ".jpg";&lt;br /&gt; document.ShowRoom.src = sImage;&lt;br /&gt; }&lt;br /&gt; &amp;lt;/script&amp;gt;&lt;br /&gt; &amp;lt;/head&amp;gt;&lt;br /&gt; &amp;lt;body&amp;gt;&lt;br /&gt; &amp;lt;table width="800"&amp;gt;&lt;br /&gt; &amp;lt;tr&amp;gt;&lt;br /&gt; &amp;lt;td valign="top" width="160"&amp;gt;&lt;br /&gt; &amp;lt;p&amp;gt;&lt;br /&gt; &amp;lt;a onmouseover="ShowPic('outsidefront')" href="http://www.wollinweb.com/blogimages/images/outsidefront.jpg"&amp;gt;Outside front&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt; &amp;lt;a onmouseover="ShowPic('bedroom3')" href="http://www.wollinweb.com/blogimages/images/bedroom3.jpg" alt="Office/third bedroom"&amp;gt;Office/third bedroom&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt; &amp;lt;a onmouseover="ShowPic('bathroom2')" href="http://www.wollinweb.com/blogimages/images/bathroom2.jpg" alt="Second bathroom"&amp;gt;Second bathroom&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt; &amp;lt;a onmouseover="ShowPic('bedroom2')" href="http://www.wollinweb.com/blogimages/images/bedroom2.jpg" alt="Second bedroom"&amp;gt;Second bedroom&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt; &amp;lt;a onmouseover="ShowPic('livingroom1')" href="http://www.wollinweb.com/blogimages/images/livingroom1.jpg" alt="Living room"&amp;gt;Living room&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt; &amp;lt;a onmouseover="ShowPic('diningroom')" href="http://www.wollinweb.com/blogimages/images/diningroom.jpg" alt="Dining room"&amp;gt;Dining room&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt; &amp;lt;a onmouseover="ShowPic('masterbed1')" href="http://www.wollinweb.com/blogimages/images/masterbed1.jpg" alt="Master bedroom"&amp;gt;Master bedroom&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt; &amp;lt;a onmouseover="ShowPic('masterbath1')" href="http://www.wollinweb.com/blogimages/images/masterbath1.jpg" alt="Master bathroom"&amp;gt;Master bathroom&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt; &amp;lt;a onmouseover="ShowPic('laundryroom')" href="http://www.wollinweb.com/blogimages/images/laundryroom.jpg" alt="Laundry room"&amp;gt;Laundry room&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt; &amp;lt;a onmouseover="ShowPic('kitchen')" href="http://www.wollinweb.com/blogimages/images/kitchen.jpg" alt="Kitchen"&amp;gt;Kitchen&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt; &amp;lt;a onmouseover="ShowPic('sittingroom')" href="http://www.wollinweb.com/blogimages/images/sittingroom.jpg" alt="Sitting room"&amp;gt;Sitting room&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt; &amp;lt;a onmouseover="ShowPic('patio1')" href="http://www.wollinweb.com/blogimages/images/patio1.jpg" alt="Rear outside patio"&amp;gt;Rear outside patio&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt; &amp;lt;/p&amp;gt;&lt;br /&gt; &amp;lt;/td&amp;gt;&lt;br /&gt; &amp;lt;td&amp;gt;&amp;lt;img name="ShowRoom" src="http://www.wollinweb.com/blogimages/images/outsidefront.jpg"&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt; &amp;lt;/tr&amp;gt;&lt;br /&gt; &amp;lt;/table&amp;gt;&lt;br /&gt; &amp;lt;/body&amp;gt;&lt;br /&gt; &amp;lt;/html&amp;gt;&lt;/code&gt;&lt;/pre&gt; &lt;p&gt;The HTML above uses absolute paths to the image, so you can just copy it to a new page in FrontPage (replacing all the HTML in the page), and view it in the browser.&lt;/p&gt; &lt;p&gt;I hope you enjoy this tip.&amp;nbsp; It's simple, but mouseovers can be very powerful.&amp;nbsp; Next tip, I'll show you how to get image mouseovers in navigation bars where you are changing the image on mouseover and then back to the original image on mouseout. (Oh, BTW, this script works without problem in IE, Moz, NN, and Opera.)&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=248763" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/lisawoll/archive/tags/Tips+and+Tricks/default.aspx">Tips and Tricks</category><category domain="http://blogs.msdn.com/lisawoll/archive/tags/JavaScript/default.aspx">JavaScript</category></item><item><title>Creating a Drop-down Menu</title><link>http://blogs.msdn.com/lisawoll/archive/2004/10/05/238395.aspx</link><pubDate>Wed, 06 Oct 2004 02:44:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:238395</guid><dc:creator>lisawoll</dc:creator><slash:comments>16</slash:comments><comments>http://blogs.msdn.com/lisawoll/comments/238395.aspx</comments><wfw:commentRss>http://blogs.msdn.com/lisawoll/commentrss.aspx?PostID=238395</wfw:commentRss><description>&lt;p&gt;We had an article on MSDN for creating a drop-down menu, but after repeated attempts, I, like many of our customers, couldn't make the code work, so we're in the process of removing it.&amp;nbsp; We will (mostly likely) eventually replace it.&amp;nbsp; In the meantime, though, I promised that I would provide an alternative.&amp;nbsp; I have working code for a drop-down menu that works in IE, Mozilla, and Netscape Navigator (sort of -- I've noticed some funky onmouseout behavior in Mozilla and Netscape Navigator that I haven't been able to resolve).&lt;/p&gt; &lt;p&gt;The example is comprised of HTML, JavaScript, and CSS and is contained in the following two files:&lt;/p&gt; &lt;ul&gt; &lt;li&gt; &lt;a target="_blank" href="http://www.wollinweb.com/blogimages/horizmenu.htm"&gt;Drop-down menu example&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a target="_blank" href="http://www.wollinweb.com/blogimages/web.htm"&gt;CSS style sheet&lt;/a&gt; (or &lt;a href="http://www.wollinweb.com/blogimages/web.css"&gt;download it&lt;/a&gt;)&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;Here's a simple explanation of the menu table and the accompanying script.&lt;/p&gt; &lt;p&gt;&lt;b&gt;Menu Table&lt;/b&gt;&lt;/p&gt; &lt;p&gt;The menu table is simple, but to make it to be usable on any ... uh, almost ... page, I surrounded the entire table with a DIV element.&amp;nbsp; The following code shows a shortened version of the menu table with the DIV element.&amp;nbsp; The DIV element has an &lt;b&gt;id &lt;/b&gt;attribute value so that the JavaScript code can access the child elements.&amp;nbsp; This was necessary in order to allow anyone who might use this code to have &amp;lt;div&amp;gt; tags elsewhere on the page without interfering with the expand/collapse functions of the JavaScript.&lt;/p&gt; &lt;pre&gt;&amp;lt;div id=&amp;quot;menu&amp;quot;&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;table width=&amp;quot;100%&amp;quot;&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;tr&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;td&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;... (missing code)&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/td&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/tr&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/table&amp;gt;&lt;br /&gt; &amp;lt;/div&amp;gt;&lt;/pre&gt; &lt;p&gt;The table has a width of 100%, but if you wanted to specify an exact pixel measurement, you could easily do that without messing up the menus.&amp;nbsp; The table is comprised of one row (TR element) with multiple columns (TD elements).&amp;nbsp; In the live version, there are five columns with drop-down menus.&amp;nbsp; Each drop-down menu lives within its own cell in the table.&amp;nbsp; The code within this TD element is somewhat complex to provide for the proper expand/collapse funtionality of the drop-down menu.&amp;nbsp; The following shows the code for the first TD element.&amp;nbsp; Each of the TD elements are almost exactly the same with a few exceptions, which I'll explain in a moment.&lt;/p&gt; &lt;pre&gt;&amp;lt;td class=&amp;quot;button&amp;quot; width=&amp;quot;20%&amp;quot; valign=&amp;quot;top&amp;quot; id=&amp;quot;item1&amp;quot;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;onmouseover=&amp;quot;expand(this.id, 'menu1');&amp;quot;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;onmouseout=&amp;quot;collapse(this.id, 'menu1');&amp;quot;&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;p&amp;gt;&amp;lt;b&amp;gt;Menu 1&amp;lt;/b&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;... (missing code)&lt;br /&gt; &amp;lt;/td&amp;gt;&lt;/pre&gt; &lt;p&gt;The &lt;b&gt;class&lt;/b&gt; attribute names the style in the CSS that defines the table cells appearance when a user first displays the page.&amp;nbsp; The &lt;b&gt;width&lt;/b&gt; attribute is set to 20% so that each of the five drop-down menus will be of equal space.&amp;nbsp; Again this is an easy thing to change if you want to modify the code to suit your own needs.&amp;nbsp; The &lt;b&gt;id&lt;/b&gt; attribute is necessary as the scripts use these to access the TD element.&lt;/p&gt; &lt;p&gt;The missing code is the nested DIV element that contains the items in the drop-down menu.&amp;nbsp; The DIV element for the first menu item is shown below.&lt;/p&gt; &lt;pre&gt;&amp;lt;div id=&amp;quot;menu1&amp;quot; class=&amp;quot;exp&amp;quot; onmouseout=&amp;quot;collapse('item1', this.id);&amp;quot;&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;p class=&amp;quot;button&amp;quot;&amp;gt;&amp;lt;a href=&amp;quot;page.htm&amp;quot; class=&amp;quot;menuitem&amp;quot;&amp;gt;Item 1&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;p class=&amp;quot;button&amp;quot;&amp;gt;&amp;lt;a href=&amp;quot;page.htm&amp;quot; class=&amp;quot;menuitem&amp;quot;&amp;gt;Item 2&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;p class=&amp;quot;button&amp;quot;&amp;gt;&amp;lt;a href=&amp;quot;page.htm&amp;quot; class=&amp;quot;menuitem&amp;quot;&amp;gt;Item 3&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;p class=&amp;quot;button&amp;quot;&amp;gt;&amp;lt;a href=&amp;quot;page.htm&amp;quot; class=&amp;quot;menuitem&amp;quot;&amp;gt;Item 4&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt; &amp;lt;/div&amp;gt;&lt;/pre&gt; &lt;p&gt;The nested DIV element also provides a value for the &lt;b&gt;id&lt;/b&gt; attribute. Again, the &lt;b&gt;class&lt;/b&gt; attribute specifies the style to use when displaying the menu. Within the DIV element are paragraphs (P elements), with a &lt;b&gt;class&lt;/b&gt; attribute value of &amp;quot;button&amp;quot;, a style defined in the attached CSS file, and links (A elements), with a &lt;b&gt;class&lt;/b&gt; attribute value of &amp;quot;menuitem&amp;quot;, another style defined in the attached CSS.&amp;nbsp; The menuitem style defines link, visited, hover, and active link styles.&lt;/p&gt; &lt;p&gt;Then, of course, there are the &lt;b&gt;onmouseover&lt;/b&gt; and &lt;b&gt;onmouseout&lt;/b&gt; events. The top-level menu item, contained in the TD element, specifies both the &lt;b&gt; onmouseover&lt;/b&gt; and &lt;b&gt;onmouseout&lt;/b&gt; events.&amp;nbsp; However, the drop-down menu, contained in the nested DIV element, specifies only the &lt;b&gt;onmouseout&lt;/b&gt; event.&amp;nbsp; The JavaScript functions that these events call require both the &lt;b&gt;id &lt;/b&gt;attribute for the TD element and the nested DIV element. &lt;/p&gt; &lt;p&gt;If you modify this script, adding or removing drop-down menus, you will want to change the second argument for these events. The following code shows the parts that you will need to change as you add and remove menus. The red code shows the &lt;b&gt;id&lt;/b&gt; attribute for the top-level menu item (TD element) and all the places where you would need to change this in the event function calls, and the blue code shows the &lt;b&gt;id&lt;/b&gt; attribute for the drop-down menu (DIV element) and all the places where you would need to change this in the event functions calls.&amp;nbsp; Basically, all the code in red must match and all the code in blue must match.&lt;/p&gt; &lt;pre&gt;&amp;lt;td class=&amp;quot;button&amp;quot; width=&amp;quot;20%&amp;quot; valign=&amp;quot;top&amp;quot; id=&amp;quot;&lt;font color="#FF0000"&gt;item1&lt;/font&gt;&amp;quot;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;onmouseover=&amp;quot;expand(this.id, '&lt;font color="#0000FF"&gt;menu1&lt;/font&gt;');&amp;quot;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;onmouseout=&amp;quot;collapse(this.id, '&lt;font color="#0000FF"&gt;menu1&lt;/font&gt;');&amp;quot;&amp;gt;&amp;lt;p&amp;gt;&amp;lt;b&amp;gt;&lt;font color="#800080"&gt;Menu 1&lt;/font&gt;&amp;lt;/b&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;div id=&amp;quot;&lt;font color="#0000FF"&gt;menu1&lt;/font&gt;&amp;quot; class=&amp;quot;exp&amp;quot; onmouseout=&amp;quot;collapse('&lt;font color="#FF0000"&gt;item1&lt;/font&gt;', this.id);&amp;quot;&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;p class=&amp;quot;button&amp;quot;&amp;gt;&amp;lt;a href=&amp;quot;&lt;font color="#800080"&gt;page.htm&lt;/font&gt;&amp;quot; class=&amp;quot;menuitem&amp;quot;&amp;gt;&lt;font color="#800080"&gt;Item 1&lt;/font&gt;&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;p class=&amp;quot;button&amp;quot;&amp;gt;&amp;lt;a href=&amp;quot;&lt;font color="#800080"&gt;page.htm&lt;/font&gt;&amp;quot; class=&amp;quot;menuitem&amp;quot;&amp;gt;&lt;font color="#800080"&gt;Item 2&lt;/font&gt;&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;p class=&amp;quot;button&amp;quot;&amp;gt;&amp;lt;a href=&amp;quot;&lt;font color="#800080"&gt;page.htm&lt;/font&gt;&amp;quot; class=&amp;quot;menuitem&amp;quot;&amp;gt;&lt;font color="#800080"&gt;Item 3&lt;/font&gt;&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;p class=&amp;quot;button&amp;quot;&amp;gt;&amp;lt;a href=&amp;quot;&lt;font color="#800080"&gt;page.htm&lt;/font&gt;&amp;quot; class=&amp;quot;menuitem&amp;quot;&amp;gt;&lt;font color="#800080"&gt;Item 4&lt;/font&gt;&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/div&amp;gt; &lt;br /&gt;&amp;lt;/td&amp;gt;&lt;/pre&gt; &lt;p&gt;&lt;b&gt;Notes&lt;/b&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Because the event function calls use &lt;code&gt;this.id&lt;/code&gt;, there's no need to specify the &lt;b&gt;id&lt;/b&gt; attribute values for these.&lt;/li&gt; &lt;li&gt;The code is purple above is code that you can safely change without affecting how the menus function.&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;If you look at the full code in the page (see Drop-down menu example above), the only difference between each of the TD/DIV element pairs is the &lt;b&gt;id&lt;/b&gt; attribute value.&amp;nbsp; You'll notice that each menu is numbered consecutively (i.e., item1/menu1, item2/menu2, item3/menu3, etc.).&amp;nbsp; I did this for ease of use.&amp;nbsp; You can, of course, provide any &lt;b&gt;id&lt;/b&gt; attribute values you want, as long as they're not the same as another element on the page and as long as you change the appropriate arguments in the event function calls so that they match as shown above.&lt;/p&gt; &lt;p&gt;&lt;b&gt;JavaScript Functions&lt;/b&gt;&lt;/p&gt; &lt;p&gt;Now for the functions. There are three functions: one for collapsing all drop-down menus, one for expanding a single menu, and one for collapsing a single menu.&lt;/p&gt; &lt;p&gt;The first one, called collapseAll, collapses all menus. The collapseAll function takes no arguments and is called once when the page loads in the &lt;b&gt;onload&lt;/b&gt; event for the BODY. This code is relatively simple and is shown in the following example:&lt;/p&gt; &lt;pre&gt;function collapseAll()&lt;br /&gt; {&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;var menuDiv = document.getElementById(&amp;quot;menu&amp;quot;);&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;var divs = menuDiv.getElementsByTagName(&amp;quot;div&amp;quot;);&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;var div;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;for (i = 0; i &amp;lt; divs.length; i++)&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;div = divs[i];&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;div.style.visibility = &amp;quot;hidden&amp;quot;;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;div.style.display = &amp;quot;none&amp;quot;;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt; }&lt;/pre&gt; &lt;p&gt;The second function, called expand, is where most of the action happens ... uh, at least half of it.&amp;nbsp; The expand function has two parameters: Then, the function is basically a bunch of scripted CSS that is used to show the DIV element and change the appearance of the top-level menu.&amp;nbsp; The expand function is shown below:&lt;/p&gt; &lt;pre&gt;function expand(s, m)&lt;br /&gt; {&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;var browser = window.navigator.appName;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;var dif = 0;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;if (browser != &amp;quot;Microsoft Internet Explorer&amp;quot;) { dif = 12; }&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;var d = document.getElementById(m);&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;var td = document.getElementById(s);&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;var left = td.offsetLeft;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;var top = td.offsetTop + 58;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;var width = td.offsetWidth - dif;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;td.style.color = &amp;quot;&lt;font color="#800080"&gt;#FFFFFF&lt;/font&gt;&amp;quot;;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;td.style.backgroundColor = &amp;quot;&lt;font color="#800080"&gt;#686496&lt;/font&gt;&amp;quot;;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;d.style.top = top;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;d.style.left = left;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;d.style.width = width;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;d.style.position = &amp;quot;absolute&amp;quot;;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;d.style.visibility = &amp;quot;visible&amp;quot;;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;d.style.display = &amp;quot;block&amp;quot;;&lt;br /&gt; }&lt;br /&gt; &lt;/pre&gt; &lt;p&gt;There are a few things you should know about this code.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;First, there is a difference between how IE displays the menu and how Mozilla and Netscape Navigator display the menu. (Note that I haven't tested this code in Opera.)&amp;nbsp; In Moz and NN, the width doesn't show up properly, so I had to specify a value that would account for the difference between the offsetWidth and the actual width of the table in these browsers.&amp;nbsp; The number isn't arbitrary; I determined it by trial and error, and this was the only number than worked.&amp;nbsp; I have no idea why this is different only that it is and this number fixes it.&amp;nbsp; If you make huge changes to the menu, this number may need to be changed also.&lt;/li&gt; &lt;li&gt;Second, the number added to the offsetTop value accounts for the height of the first line in the top-level menu as well as the top heading paragraph.&amp;nbsp; Again, this number is not arbitrary and accounts for the space between the top of the browser and the top of the drop-down menu. I arrived at this number by a trial and error process.&amp;nbsp; If your top-level menu text runs onto multiple lines and/or you have a large graphic heading or other things above the menu bar, this number will likely change.&lt;/li&gt; &lt;li&gt;Third, if you want to change the appearance of the menu, you can change any of the values in purple in the code above to appropriate and desired values without affecting how the script functions.&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;And finally, the third function, called collapse, collapses a single drop-down menu.&amp;nbsp; This is where the other half of the action happens.&amp;nbsp; The collapse function has two parameters: the first is the &lt;b&gt;id&lt;/b&gt; attribute value for the TD element (the top-level menu item), the second is is the &lt;b&gt;id&lt;/b&gt; attribute value for the nested DIV element (the drop-down menu). The collapse function is shown in the following code:&lt;/p&gt; &lt;pre&gt;function collapse(s, m)&lt;br /&gt; {&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;var d = document.getElementById(m);&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;var td = document.getElementById(s);&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;td.style.color = &amp;quot;&lt;font color="#800080"&gt;black&lt;/font&gt;&amp;quot;;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;td.style.backgroundColor = &amp;quot;&lt;font color="#800080"&gt;#EEEEEE&lt;/font&gt;&amp;quot;;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;d.style.position = &amp;quot;static&amp;quot;;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;d.style.visibility = &amp;quot;hidden&amp;quot;;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;d.style.display = &amp;quot;none&amp;quot;;&lt;br /&gt; }&lt;/pre&gt; &lt;p&gt;There's absolutely nothing major about this code.&amp;nbsp; It changes the appearance of the TD element back to the original formatting, and hides the DIV element.&amp;nbsp; Ideally, this formatting would match what is in the attached CSS, which in this case, it does. You can change any of the values in purple in the code above to appropriate and desired values without affecting how the script functions.&lt;/p&gt; &lt;p&gt;&lt;b&gt;Conclusion&lt;/b&gt;&lt;/p&gt; &lt;p&gt;And that's all there is to it.&amp;nbsp; Have fun using this, and if you need help, please let me know. If you are looking for a drop-down menu, feel free to use it, or if you do an Internet search, you will find many more examples and just as many ways to create drop-down menus, and many of them much cooler than my litte example here.&lt;/p&gt; &lt;p&gt;Have fun, and enjoy playing with the code, and if you can tell me what's up with the Mozilla/Netscape issue, please do.&amp;nbsp; I've tried all types of arrangements for the code to see if order made a difference, if putting the event function call in a different place made a difference, and I've been relatively unsuccessful getting it to be completely functional in these browsers.&amp;nbsp; Sometimes the &lt;b&gt;onmouseout&lt;/b&gt; event just doesn't fire.&lt;/p&gt; &lt;p&gt;Anyway, as usual, my only real caveat is that the code won't work at all if the user has scripting turned off in their browser, but IMHO, that's not a reason to not use it or any other script.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=238395" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/lisawoll/archive/tags/Tips+and+Tricks/default.aspx">Tips and Tricks</category><category domain="http://blogs.msdn.com/lisawoll/archive/tags/JavaScript/default.aspx">JavaScript</category></item><item><title>Creating a drop-down list that links to other pages</title><link>http://blogs.msdn.com/lisawoll/archive/2004/08/19/217427.aspx</link><pubDate>Thu, 19 Aug 2004 22:33:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:217427</guid><dc:creator>lisawoll</dc:creator><slash:comments>31</slash:comments><comments>http://blogs.msdn.com/lisawoll/comments/217427.aspx</comments><wfw:commentRss>http://blogs.msdn.com/lisawoll/commentrss.aspx?PostID=217427</wfw:commentRss><description>&lt;p&gt;You've seen them.&amp;nbsp; All the big Web sites have them.&amp;nbsp; Now you want one, too.&amp;nbsp; Perhaps you have localized sites and you want a cover page with a drop-down that lists the different languages into which your Web site is translated so that visitors can select the language they want to view.&amp;nbsp; Maybe you want to use a drop-down for navigation for your site or to allow site visitors to access online search engines.&amp;nbsp; There could be any number of reasons why you want to do it.&amp;nbsp; Or maybe there's no reason at all.&amp;nbsp; You just want to know how to do it because you think it looks cool.&lt;/p&gt; &lt;p&gt;There are two types of drop-down lists that hyperlink to other pages:&amp;nbsp; one, the &lt;a href="#selection"&gt;page changes when the selection changes&lt;/a&gt;; two, the &lt;a href="#clickgo"&gt;page changes when the visitor clicks a button&lt;/a&gt;.&amp;nbsp; I'm going to give you JavaScript code to do both of these, but there is of course, one limitation.&amp;nbsp; As always, if the user has JavaScript disabled, then the simple examples that I provide here won't work.&amp;nbsp; In this case, you could use ASP, ASP.NET, or another server-side processing technology to provide this functionality.&lt;/p&gt; &lt;p&gt;&lt;b&gt;&lt;a name="selection"&gt;&lt;/a&gt;Page changes when the selection changes&lt;/b&gt;&lt;/p&gt; &lt;p&gt;Creating a dropdown that causes a new page to open when the selection changes is fairly simple to do.&amp;nbsp; The user doesn't have to do anything except select the item from the drop-down and the page opens.&amp;nbsp; I used the &lt;b&gt;open&lt;/b&gt; method, but you could also use the &lt;b&gt;navigate&lt;/b&gt; method.&lt;/p&gt; &lt;p&gt;Here's the script:&lt;/p&gt;&lt;pre&gt;&lt;code&gt;&amp;lt;script&amp;gt;&lt;br /&gt; &lt;/code&gt;&lt;code&gt;function goToPage(url)&lt;br /&gt; {&lt;br /&gt; if (url != "")&lt;br /&gt; {&lt;br /&gt; .open(url);&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;/code&gt;&lt;/pre&gt; &lt;p&gt;And here's the dropdown.&amp;nbsp; Note that the form tag is necessary for the script to function properly.&lt;/p&gt;&lt;pre&gt;&lt;code&gt;&amp;lt;form&amp;gt;&lt;br /&gt; &amp;lt;label&amp;gt;&amp;lt;u&amp;gt;S&amp;lt;/u&amp;gt;earch Engines&amp;lt;/label&amp;gt;&lt;br /&gt; &amp;lt;select accesskey="S" onchange="goToPage(this.options(this.selectedIndex).value)"&amp;gt;&lt;br /&gt; &lt;/code&gt;&lt;code&gt;&amp;lt;option selected&amp;gt;Please select one&amp;lt;/option&amp;gt;&lt;br /&gt; &amp;lt;option value="http://search.msn.com/"&amp;gt;MSN Search&amp;lt;/option&amp;gt;&lt;br /&gt; &amp;lt;option value="http://www.google.com/"&amp;gt;Google&amp;lt;/option&amp;gt;&lt;br /&gt; &amp;lt;option value="http://www.search.com/"&amp;gt;Search.com&amp;lt;/option&amp;gt;&lt;br /&gt; &amp;lt;option value="http://www.dogpile.com/"&amp;gt;Dogpile&amp;lt;/option&amp;gt;&lt;br /&gt; &amp;lt;/select&amp;gt;&lt;br /&gt;form&amp;gt;&lt;/code&gt;&lt;/pre&gt; &lt;p&gt;&lt;b&gt;&lt;a name="clickgo"&gt;&lt;/a&gt;Page changes when the user click a button&lt;/b&gt;&lt;/p&gt; &lt;p&gt;Creating a dropdown that uses a Go button is just as simple. When the user has selected the item they want from the dropdown, they just click Go, and the new page opens. I used the &lt;b&gt;open&lt;/b&gt; method for this script also, but you could use the &lt;b&gt;navigate&lt;/b&gt; method here as well.&lt;/p&gt; &lt;p&gt;Here's the script:&lt;/p&gt;&lt;pre&gt;&lt;code&gt;&amp;lt;script&amp;gt;&lt;br /&gt;function goToNewPage(dropdownlist)&lt;br /&gt; {&lt;br /&gt; var url = dropdownlist.options(dropdownlist.selectedIndex).value;&lt;br /&gt; if (url != "")&lt;br /&gt; {&lt;br /&gt; window.open(url);&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;/code&gt;&lt;/pre&gt; &lt;p&gt;And here's the dropdown. Note that the form tag is necessary for the script to function properly.&lt;/p&gt;&lt;pre&gt;&lt;code&gt;&amp;lt;form name="dropdown"&amp;gt;&lt;br /&gt; &amp;lt;label&amp;gt;Search &amp;lt;u&amp;gt;E&amp;lt;/u&amp;gt;ngines&amp;lt;/label&amp;gt;&lt;br /&gt; &amp;lt;select name="list" accesskey="E"&amp;gt;&lt;br /&gt; &amp;lt;option selected&amp;gt;Please select one&amp;lt;/option&amp;gt;&lt;br /&gt; &amp;lt;option value="http://search.msn.com/"&amp;gt;MSN Search&amp;lt;/option&amp;gt;&lt;br /&gt; &amp;lt;option value="http://www.google.com/"&amp;gt;Google&amp;lt;/option&amp;gt;&lt;br /&gt; &amp;lt;option value="http://www.search.com/"&amp;gt;Search.com&amp;lt;/option&amp;gt;&lt;br /&gt; &amp;lt;option value="http://www.dogpile.com/"&amp;gt;Dogpile&amp;lt;/option&amp;gt;&lt;br /&gt; &amp;lt;select&amp;gt;&lt;br /&gt; &amp;lt;input type=button value="Go" onclick="goToNewPage(document.dropdown.list)"&amp;gt;&lt;br /&gt;&amp;lt;/form&amp;gt;&lt;/code&gt;&lt;/pre&gt; &lt;p&gt;In order to use this code, all you need to do is copy the code above, switch to &lt;b&gt;Code&lt;/b&gt; view in FrontPage, and paste it into your page.&amp;nbsp; Once you do this, change text displayed and the &lt;b&gt;value&lt;/b&gt; attribute for each option in the SELECT element.&amp;nbsp; The &lt;b&gt;value&lt;/b&gt; attributes should contain a valid URL including the "http://".&amp;nbsp; Place the script code in the HEAD section of your page, and place the form with the SELECT element anywhere on the page where you want it to appear.&amp;nbsp; You can have more than one form on a page.&amp;nbsp; Just don't nest this FORM element inside of another FORM element.&amp;nbsp; If you do so, you will likely experience problems.&lt;/p&gt; &lt;p&gt;&lt;b&gt;What's the difference?&lt;/b&gt;&lt;/p&gt; &lt;p&gt;The only differences between the two examples above are the location of the event that calls the script (which in the first is in the &lt;b&gt;onchange&lt;/b&gt; event for the SELECT element, and in the second is in the &lt;b&gt;onclick&lt;/b&gt; event for the Go button) and the way the SELECT element is accessed (which for the first example is accessed by using the this keyword, and for the second is accessed using the name attributes for the FORM and SELECT elements).&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=217427" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/lisawoll/archive/tags/Tips+and+Tricks/default.aspx">Tips and Tricks</category><category domain="http://blogs.msdn.com/lisawoll/archive/tags/JavaScript/default.aspx">JavaScript</category></item><item><title>Add my page to a visitor's Favorites list</title><link>http://blogs.msdn.com/lisawoll/archive/2004/07/13/182613.aspx</link><pubDate>Wed, 14 Jul 2004 00:03:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:182613</guid><dc:creator>lisawoll</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/lisawoll/comments/182613.aspx</comments><wfw:commentRss>http://blogs.msdn.com/lisawoll/commentrss.aspx?PostID=182613</wfw:commentRss><description>&lt;P&gt;Here's a tip that &lt;A href="#jim"&gt;Jim Buyens&lt;B&gt;*&lt;/B&gt;&lt;/A&gt;, a FrontPage MVP, contributed awhile ago that shows how to create a link that adds a Web page to a visitor's list of Favorites.&lt;/P&gt;
&lt;P&gt;Switch to &lt;B&gt;Code&lt;/B&gt; view and add this script where you want the hyperlink to appear:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;script&amp;gt;
  if (navigator.appName.substring(0,9) == "Microsoft")
  {
    document.write("&amp;lt;a href='" +
      "javascript:window.external.addFavorite" +
      "(document.location, document.title)'&amp;gt;" +
      "Add to favorites.&amp;lt;/a&amp;gt;")
  }
&amp;lt;/script&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This script works unmodified in any page. The expression &lt;B&gt;&lt;CODE&gt;document.location&lt;/CODE&gt;&lt;/B&gt; gets the URL of the page that contains the script, and the expression &lt;B&gt;&lt;CODE&gt;document.title&lt;/CODE&gt;&lt;/B&gt; gets the page title. This is the title you enter in FrontPage on the &lt;B&gt;General&lt;/B&gt; tab of the &lt;B&gt;Page Properties&lt;/B&gt; dialog box. &lt;/P&gt;
&lt;P&gt;Unfortunately, the &lt;B&gt;&lt;CODE&gt;window.external.addFavorite()&lt;/CODE&gt;&lt;/B&gt; method that makes all this possible works only in Internet Explorer. An if statement therefore tests the first nine characters of the browser's identification string for the presence of the word &amp;quot;Microsoft&amp;quot;. This condition will be false for any browser other than Internet Explorer, and as a result, the link won't appear in those browsers.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;*&lt;/B&gt; &lt;A href="http://www.interlacken.com" target=_blank&gt;Jim Buyens &lt;/A&gt;is the author of ten computer books, including most recently &lt;A href="http://www.microsoft.com/mspress/books/5597.asp" target=_blank&gt;Microsoft Office FrontPage 2003 Inside Out&lt;/A&gt;, from Microsoft Press, ISBN 0-7356-1510-1.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=182613" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/lisawoll/archive/tags/Tips+and+Tricks/default.aspx">Tips and Tricks</category><category domain="http://blogs.msdn.com/lisawoll/archive/tags/JavaScript/default.aspx">JavaScript</category></item><item><title>Open a page in a new window of a specific size</title><link>http://blogs.msdn.com/lisawoll/archive/2004/07/06/174509.aspx</link><pubDate>Wed, 07 Jul 2004 00:05:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:174509</guid><dc:creator>lisawoll</dc:creator><slash:comments>31</slash:comments><comments>http://blogs.msdn.com/lisawoll/comments/174509.aspx</comments><wfw:commentRss>http://blogs.msdn.com/lisawoll/commentrss.aspx?PostID=174509</wfw:commentRss><description>&lt;P&gt;I've often seen questions in the FrontPage Programming newsgroup for code to programmatically open a page in a browser window that is of a specifc size.&amp;nbsp; Of course, using the &lt;B&gt;target&lt;/B&gt; attribute of the A element, you can easily open a new page in a new browser window, but it will be the same size as other browser windows.&amp;nbsp; However, sometimes you may want to have a smaller browser window, or you may not want the user to be able to resize the window.&amp;nbsp; Perhaps you want to remove the menu bar, address bar, status bar, or scroll bars. Today's tip shows JavaScript for doing this.&lt;/P&gt;
&lt;P&gt;The code is fairly simple, but there are a few ways to do this.&amp;nbsp; One way uses the &lt;A href="#open"&gt;&lt;B&gt;open&lt;/B&gt;&lt;/A&gt; method; another way uses the&amp;nbsp; &lt;B&gt;&lt;A href="#modal"&gt;showModalDialog&lt;/A&gt;&lt;/B&gt; method; and another way uses the &lt;B&gt;&lt;A href="#modeless"&gt;showModelessDialog&lt;/A&gt;&lt;/B&gt; method.&amp;nbsp; I'll explain each of these below.&lt;/P&gt;&lt;A name=open&gt;&lt;/A&gt;
&lt;P&gt;&lt;B&gt;open Method&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;The &lt;B&gt;open&lt;/B&gt; method does just that:&amp;nbsp; it opens a new page.&amp;nbsp; Similar to the &lt;B&gt;navigate&lt;/B&gt; method, by default it will open the page in the current browser window.&amp;nbsp; However, unlike the &lt;B&gt;navigate&lt;/B&gt; method, the &lt;B&gt;open&lt;/B&gt; method also has parameters that allow for opening in a new window and for specifying the appearance of that window.&amp;nbsp; The &lt;B&gt;open&lt;/B&gt; method has the following signature:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;window.open( [sURL] [, sName] [, sFeatures] [, bReplace])&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you take a look at the &lt;A href="http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/open_0.asp" target=_blank&gt;help topic&lt;/A&gt; for the &lt;B&gt;open&lt;/B&gt; method, you will get specific information about each of the parameters, but here are the basics:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;sURL is the address for the new page. 
&lt;LI&gt;sName is the value of the &lt;B&gt;target&lt;/B&gt; attribute for an A element; which for this tip will be "_blank" to open a new window, but which could be the name of a frame or another window. 
&lt;LI&gt;sFeatures specifies the display options for the window, including height and width. 
&lt;LI&gt;bReplace specifies whether the new URL is added to or replaces an item in the browser's history list. &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;For this tip, we are only concerned with the first three parameters and will omit the fourth.&amp;nbsp; So here's the code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;function openNewWindow()
{
    window.open("http://www.microsoft.com", "_blank", 
        "height=340px width=240px");
}&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This code opens a new browser window that is 340 pixels high and 240 pixels wide and displays the Microsoft home page.&amp;nbsp; You could add options to the sFeatures parameter string to hide the status bar, hide the scroll bars, prohibit resizing the window, and more.&amp;nbsp; The help topic noted above has the complete list of options and possible values.&amp;nbsp; All you need to do is add them to the sFeatures parameter string, separating each name=value pair with a space.&lt;/P&gt;&lt;A name=modal&gt;&lt;/A&gt;
&lt;P&gt;&lt;B&gt;showModalDialog Method&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;The &lt;B&gt;showModalDialog&lt;/B&gt; method is another way to show a page in a new window of a specific size, but when you use the &lt;B&gt;showModalDialog&lt;/B&gt; method, the user can't return to the first window until he/she closes the modal dialog window.&amp;nbsp; This is especially useful when you need you need to return values from the dialog (which I'll save for a future tip).&amp;nbsp;When you use the &lt;B&gt;showModalDialog&lt;/B&gt; method to open a new window, the new browser window cannot be resized. The signature for the &lt;B&gt;showModalDialog&lt;/B&gt; method is as follows:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;window.showModalDialog(sURL [, vArguments] [, sFeatures])&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you look at the &lt;A href="http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/showmodaldialog.asp" target=_blank&gt;help topic&lt;/A&gt; for the &lt;B&gt;showModalDialog&lt;/B&gt; method, you will get specific information about each of the parameters, but here are the basics:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;sURL is the address for the new page. 
&lt;LI&gt;vArguments passes values to the dialog box. 
&lt;LI&gt;sFeatures specifies the display options for the dialog box, such as height, width, and whether to show the help button, scroll bars, menu bar, etc. &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;For this tip, we are concerned only with the first and third parameters.&amp;nbsp; Here's the code:&lt;/P&gt;
&lt;PRE&gt;function openNewWindow()
{
    window.showModalDialog("http://www.microsoft.com", "", 
        "dialogHeight:340px; dialogWidth:240px")
}&lt;/PRE&gt;
&lt;P&gt;This code opens a new browser window that is 340 pixels high and 240 pixels wide and opens the Microsoft home page. You can add additional dialog box features by adding them to the sFeatures string, separating each name=value pair with a semicolon.&amp;nbsp; The help topic mentioned above lists all the features and possible values."&lt;/P&gt;&lt;A name=modeless&gt;&lt;/A&gt;
&lt;P&gt;&lt;B&gt;&lt;B&gt;showModelessDialog&lt;/B&gt; Method&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;The &lt;B&gt;showModelessDialog&lt;/B&gt; method is similar to the &lt;B&gt;showModalDialo&lt;/B&gt;g method except that the user can move between the first page and the modeless dialog window. As with the &lt;B&gt;showModalDialog&lt;/B&gt; method, when you use the &lt;B&gt;showModelessDialog&lt;/B&gt; method to open a new window, the new browser window cannot be resized, and the dialog box always stays on top. The signature for the &lt;B&gt;showModelessDialog&lt;/B&gt; method is as follows:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;window.showModelessDialog(sURL [, vArguments] [, sFeatures])&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You will notice that the signature for the &lt;B&gt;showModelessDialog&lt;/B&gt; method is the same as the &lt;B&gt;showModalDialog&lt;/B&gt; method. If you look at the &lt;A href="http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/showmodelessdialog.asp" target=_blank&gt;help topic&lt;/A&gt; for the &lt;B&gt;showModelessDialog&lt;/B&gt; method, you will get specific information about each of the parameters and the possible values.&amp;nbsp; As with the previous code, for this tip, we are concerned only with the first and third parameters.&amp;nbsp; Here's the code:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;code&gt;function openNewWindow()
{
    window.showModelessDialog("http://www.microsoft.com", "",
        "dialogHeight:340px; dialogWidth:240px")
}&lt;/code&gt;&lt;/PRE&gt;
&lt;P&gt;You'll probably notice that the only difference between this code sample and the previous one is the name of the method.&amp;nbsp; This is because the signatures are basically the same.&amp;nbsp; You can add options to the sFeatures parameter to change the look of the dialog box. &lt;/P&gt;
&lt;P&gt;&lt;B&gt;Pulling it All Together&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;In my typical style, I like to make things difficult, so here's a final code sample that creates a new window that is 300 by 500 pixels, removes the scroll bars, address bar, menu bar, and status bar, and prohibits resizing.&lt;/P&gt;
&lt;PRE&gt;&lt;code&gt;function openNewWindow(newPageURL)
{
    window.open(newPageURL, "_blank","height=500px width=300px " +
        "resizable=no scrollbars=no menubar=no location=no status=no");
}&lt;/code&gt;&lt;/PRE&gt;
&lt;P&gt;To add this code, or any of the previous examples, to a Web page, just paste the function in a &amp;lt;SCRIPT&amp;gt; block within the &amp;lt;HEAD&amp;gt; section of the page.&amp;nbsp; Then add the function, and the URL parameter, to the event that you want to access it.&amp;nbsp; For example, if you want the code to run when someone clicks on a form button, you would use the &lt;B&gt;onclick&lt;/B&gt; event, as shown in the following code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;&amp;lt;input type="button" onclick="javascript:openNewWindow('http://www.microsoft.com');" value="Click Here"&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now that you have the basics, have fun creating new windows with JavaScript.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=174509" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/lisawoll/archive/tags/Tips+and+Tricks/default.aspx">Tips and Tricks</category><category domain="http://blogs.msdn.com/lisawoll/archive/tags/JavaScript/default.aspx">JavaScript</category></item><item><title>Retain a visitor-specified value in a drop down list</title><link>http://blogs.msdn.com/lisawoll/archive/2004/06/22/162911.aspx</link><pubDate>Tue, 22 Jun 2004 21:26:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:162911</guid><dc:creator>lisawoll</dc:creator><slash:comments>23</slash:comments><comments>http://blogs.msdn.com/lisawoll/comments/162911.aspx</comments><wfw:commentRss>http://blogs.msdn.com/lisawoll/commentrss.aspx?PostID=162911</wfw:commentRss><description>&lt;P&gt;Here's a tip that &lt;A href="http://weblogs.asp.net/lisawoll/admin/EditPosts.aspx#jim"&gt;Jim Buyens&lt;B&gt;*&lt;/B&gt;&lt;/A&gt;, a FrontPage MVP, contributed some time ago for retaining a visitor-specified value in a drop down list. If you're working with databases in FrontPage, the Database Results Wizard is probably what you use most, if not every, time you want to show database results on a Web page. When you use a drop-down list to display values from a database, you have probably noticed that after you submit the form, the selection in the drop-down list referts to the first item in the list.&amp;nbsp; Jim's tip shows you how to make the drop-down list display the value that the visitor specified.&lt;/P&gt;
&lt;P&gt;Switch to &lt;B&gt;Code&lt;/B&gt; view and add a script such as the following just before the end of your form (that is, just before the &amp;lt;/form&amp;gt; tag.) &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;script&amp;gt;
   for (i = 0; i &amp;lt; document.forms[0].CategoryID.options.length; i++)
   {
      if (document.forms[0].CategoryID.options[i].value == "&amp;lt;%=request.form("CategoryID")%&amp;gt;")
      {
         document.forms[0].CategoryID.selectedIndex = i;
         break;
      }
   }
&amp;lt;/script&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This sample code assumes that the name of the drop-down list box is CategoryID. To make the script work with your list box, change all four occurrences of the name CategoryID to the name of your list box. This will be the name you specify under &lt;B&gt;Submit Values From This Field&lt;/B&gt; option on page four of the wizard.&lt;/P&gt;
&lt;P&gt;&lt;A name=jim&gt;&lt;/A&gt;&lt;BR&gt;&lt;B&gt;*&lt;/B&gt; &lt;A href="http://www.interlacken.com/" target=_blank&gt;Jim Buyens &lt;/A&gt;is the author of ten computer books, including most recently &lt;A href="http://www.microsoft.com/mspress/books/5597.asp" target=_blank&gt;Microsoft Office FrontPage 2003 Inside Out&lt;/A&gt;, from Microsoft Press, ISBN 0-7356-1510-1.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=162911" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/lisawoll/archive/tags/Tips+and+Tricks/default.aspx">Tips and Tricks</category><category domain="http://blogs.msdn.com/lisawoll/archive/tags/JavaScript/default.aspx">JavaScript</category></item><item><title>Dates, dates, and more dates...</title><link>http://blogs.msdn.com/lisawoll/archive/2004/06/11/153974.aspx</link><pubDate>Sat, 12 Jun 2004 00:40:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:153974</guid><dc:creator>lisawoll</dc:creator><slash:comments>15</slash:comments><comments>http://blogs.msdn.com/lisawoll/comments/153974.aspx</comments><wfw:commentRss>http://blogs.msdn.com/lisawoll/commentrss.aspx?PostID=153974</wfw:commentRss><description>&lt;P&gt;We get a lot of requests from people who want to put the current date on their Web pages, so I thought I would start my first official FrontPage tip with code to help accomplish this.&lt;/P&gt;
&lt;P&gt;There are a couple ways that you can get the current date onto your Web pages.&amp;nbsp; One uses client-side JavaScript, the other uses server-side code.&amp;nbsp; As always, there are advantages and disadvantages to both.&amp;nbsp; The code I'm including in this post is for client-side JavaScript because generally you want the user to see the date that they have on their local machine.&amp;nbsp; Server-side dates take their dates from the server, which could be all the way on the other side of the world.&amp;nbsp; Probably the only disadvantage to JavaScript is that users can turn scripting off in their browser.&amp;nbsp; However, if they do this, the worst that happens is that the visitor doesn't see the date.&lt;/P&gt;
&lt;P&gt;Just because I like to be difficult, I'm including several renditions of the code, each display the date slightly differently.&lt;/P&gt;
&lt;P&gt;To use any of these you just insert the one you want into a script block in the HEAD section of your page, and put an inline script block, like the following, that names the function, where "GetTodaysDate" in the following example is the name of the function.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;script language="javascript"&amp;gt;document.write(GetTodaysDate());&amp;lt;/script&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;H4&gt;Dates and Times&lt;/H4&gt;
&lt;P&gt;&lt;B&gt;6/11/2004:&lt;/B&gt;&lt;BR&gt;This one displays the current date in short format:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;function GetTodaysDate(){
    var oDate = new Date();
    var sDate = oDate.getMonth() + "/" + oDate.getDate() + "/" + oDate.getYear()
    return sDate;
}&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;B&gt;Friday, 6/11/2004:&lt;/B&gt;&lt;BR&gt;This one displays the day of the week and then the current date in short format:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;function GetTodaysDayAndDate(){
    var oDate = new Date();
    var iDay = oDate.getDay();
    var sDay;
 
    switch (iDay){
        case (0) :{sDay = "Sunday"; break;}
        case (1) :{sDay = "Monday"; break;}
        case (2) :{sDay = "Tuesday"; break;}
        case (3) :{sDay = "Wednesday"; break;}
        case (4) :{sDay = "Thursday"; break;}
        case (5) :{sDay = "Friday"; break;}
        case (6) :{sDay = "Saturday"; break;}
    }
    var sDate = oDate.getMonth() + "/" + oDate.getDate() + "/" + oDate.getYear()
    return sDay + ", " + sDate;
}&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;B&gt;Fri Jun 11 2004:&lt;/B&gt;&lt;BR&gt;This one displays the day of the week and then the current date in pseudo short format:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;function GetTodaysDateLongFormat(){
    var oDate = new Date();
    var sDate = oDate.toDateString();
    return sDate;
}&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;B&gt;17:32:&lt;/B&gt;&lt;BR&gt;his one shows the time. It's in military format, but the following example uses code that uses AM and PM.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;function GetTime(){
    var oDate = new Date();
    var sTime = oDate.getHours() + ":" + oDate.getMinutes();
    return sTime;
}&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;B&gt;5:32 PM:&lt;/B&gt;&lt;BR&gt;This one shows the time in AM / PM format.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;function GetTimeLong(){
    var oDate = new Date();
    var iHour = oDate.getHours();
    var sAmPm;
 
    if (iHour &amp;lt; 13)
    {
        sAmPm = "AM";
    }
    else
    {
        iHour = iHour - 12;
        sAmPm = "PM";
    }
    var sTime = iHour + ":" + oDate.getMinutes() + " " + sAmPm;
    return sTime;
}&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;B&gt;6/11/2004, 5:32 PM:&lt;/B&gt;&lt;BR&gt;And, finally, this one shows you date AND time. &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;function GetDateTime(){
 var oDate = new Date();
    var sDate = oDate.getMonth() + 1 + "/" + oDate.getDate() + "/" + oDate.getYear();
 var iHour = oDate.getHours();
 var sAmPm;
 
 if (iHour &amp;lt; 13)
 {
  sAmPm = "AM";
 }
 else
 {
  iHour = iHour - 12;
  sAmPm = "PM";
 }
 var sTime = iHour + ":" + oDate.getMinutes() + " " + sAmPm;
 
 return sDate + ", " + sTime;
}&lt;/CODE&gt;&lt;/PRE&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=153974" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/lisawoll/archive/tags/Tips+and+Tricks/default.aspx">Tips and Tricks</category><category domain="http://blogs.msdn.com/lisawoll/archive/tags/JavaScript/default.aspx">JavaScript</category></item></channel></rss>