The New Year Cometh and the Web Men Goeth

As of December 2011, this topic has been archived. As a result, it is no longer actively maintained. For more information, see Archived Content. For information, recommendations, and guidance regarding the current version of Internet Explorer, see Internet Explorer Developer Center.

Heidi Housten
Tom Moran
Rafael M. Munoz
Kusuma Vellanki
Microsoft Corporation

January 1, 2001

Now's the time to say goodbye to all our family, W-E-B M-E-N. All right already, you probably get the hint. The Web Team's Web Men are moving on. Before we continue down the Web Men memory lane, let us first reassure you that the Web Team Talking column will continue. The Web Team has found two great replacements to work with Kusuma and Heidi as they continue the column into the future.

As we move on, we want to thank our family of readers for making us what we are. We know we have some true-blue, loyal readers who put aside The Washington Post and The Wall Street Journal to see what the Team has to say each month, and to you we say, "Thanks."

Be sure to check back in February when the new Team will begin its journey and continue our family traditions. Till then, we wanted to take this month to bring back some memories and show you where we, as developers, have come. Enjoy, and remember that things have changed over the years, so some questions and answers probably have better solutions today.

Thanks for the memories.

Rafael and Tom

Now, to infinity—and beyond!

Contents

Slick navigation: Building a drop-down list box—Originally published June 23, 1997
Are you asking us for a date?—Originally published May 3, 1999. Remember Y2K!
Haiku Contest: Remember when we asked for haiku?—Originally published June 7, 1999
Going back and forth—Disabling the browser's Forward/Back buttonsOriginally published July 3, 2000

The Web Team in Short

Slick Navigation

Dear Web Men:

At the Site Builder Network home page, in the left-hand side, you have a selection criterion for International sites, under which you placed a drop-down menu. Usually, a drop-down menu is accompanied with a submit button. I want to know how to create the menu with a number of choices, without the submit button. When I select a choice, it must jump to the document linked using hyperlink, or otherwise. This document must appear in another frame, usually the frame used for displaying contents, the bigger one.

Thanks,

Raja Rajagopalan

The Web Men reply:

Surprise, Raja! The Web Men are everywhere. Raja actually sent the above question to one of our favorite columnists, Mary Haggard, who promptly forwarded it us, knowing this was right up our alley.

So you want to use a drop-down list box and "automagically" direct a link to be displayed in another frame, similar to what we are doing on the Site Builder Network home page. Through the miracle of JavaScript, this is fairly simple—and from previous columns, you already know that directing output to other frames is even simpler. We have created a sample with a small FORM that contains our drop-down list box menu.

View a Drop-Down List Box sample.

View the source code.

When you check out the sample, you'll notice that—nothing up our sleeves—we have created a slick way of navigating our site without having to use a submit button with the drop-down list box.

Are You Asking Us for a Date?

Dear Web Men:

I have a date on a form that is entered in MM/DD/YY format. I would like to know how to change that to a 4-digit year.

Jerry Thompson

The Web Men reply:

This is not as simple as it might appear, especially since you didn't provide a lot of background on what you are really trying to do. At first, we had written a nice little sample to show you how to convert your date, validate it, and present it for user verification. However, to quote the Genie in Disney's Aladdin: "There are a few, uh, provisos, ah, a couple a quid pro quos..." This is dangerous Y2K territory, and you need to show due diligence in understanding how to work with dates by visiting (and reading!) the link we give you below. Making a few assumptions about what you want to accomplish, the basic flow of what you need to do is this:

  • Validate the date. Did the user enter a good date, or just some random numbers? Do this on the client side through script.
  • Present it to the user as a four-digit date, both as a reminder to enter dates that way and to verify that the year is in the correct century. Date conversions make some intelligent guesses about what century a two-digit date is in, but depending on context, you may want to make sure.
  • Validate the date again after giving the user the opportunity to verify it. After all, they might have changed it again.
  • Store it properly. There are a variety of considerations here, depending on the technologies you are using and how you might later use the date. If you are going to use it for any sort of comparison, make sure you know exactly how it is stored, since sometimes time is stored as well and might lead to unexpected results.
  • And don't mess with the regional settings and the short date style to get it to look right. That is not a good approach.

As we pointed out above, this can get fairly complex—in fact, there are hundreds of pages written on the subject on Microsoft's Y2K Web site. If this were an easy problem to solve, we wouldn't have bought that compound in Eastern Washington. Note, however, that we also purchased a solar collector, so that even in the face of the collapse of civilization, Web Men Talking will still be here to answer your questions.

You Actually Wrote Haikus!

We received far more entries than we had expected for our little haiku contest. Evidently, nearly everyone thought they could do better than we did. And you weren't too far off the mark. Here are our four favorites:

Sweet Mother of God

You want me to write Haiku?

Get a %!##ing life!

Submitted by Dave Moyses

People like Web sites

That have nice flashy graphics

But not me, too slow

Submitted by Chris Williams

My ActiveX doc

Displaying in the browser.

Finally, it WORKS

Submitted by Dwayne Macadangdang

"Make it cross-browser."

"The deadline is yesterday."

Oh death, where is thy sting?

Submitted by Jonathon Brownell

Haiku is generally considered to be 5-7-5 syllables, but that isn't a strict rule.

Going Back and Forth

Dear Web Team:

Can anyone tell me if there is a way to disable the browser's Forward/Back buttons? The reason is that I can't allow the client to browse back to pages when they're on the Web site.

By disabling the Back button, I'd be okay—but so far, no luck on doing that. So I asked myself if I could delete the history list of the browser, and therefore block the back of the browser ... no can do either.

I have to find a way to catch the event back and redirect to the same page using VBScript.

Serge Dufour

The Web Team Replies:

Serge, we have answers galore to your question, and we've decided to hit you with everything we have! So brace yourself. Here they come.

There is no way to clear the session history through script, as you have found. Our mantra for most session-history questions like this is location.replace. Because you control all of the pages on your site, you can use location.replace to navigate from one page to another. This will replace the current history entry with the new page, so you always have only one entry from your site on the stack. Here's a snippet that shows how you can change your links to get this behavior.

<A HREF="next.html" ONCLICK="javascript:location.replace(this.href); event.returnValue=false; event.cancelBubble=true;">
Click here to navigate to the next page without adding the current page to the history stack.
</A>

This takes care of the Forward/Back problem. But this may not be the complete answer, depending on why you need this functionality. Is the main intention not to allow users to view the page again in that session? If so, you also have to prevent users from accessing this page by typing in the URL manually. Or is your intention to pull the page from the server each time, instead of from the cache, as would happen when the user clicks on the Forward/Back buttons?

The answer to the first question is pretty simple. You can use a session variable that is set when the user first requests a page, and the value of that variable will determine whether the user is allowed to access the page in the same session again.

The second question is a little more complicated. Internet Explorer 4.0 used the cache headers even when the user clicked on the Forward/Back buttons. Internet Explorer 5 complies with the HTTP specification, which states that when the user clicks on the Forward/Back buttons, the pages should be shown to the user exactly as they were viewed when they were saved in the history. In either case, you can still add HTTP headers to prevent the file from being cached on disk, which will force the browser to request it from the server. Refer to the Knowledge Base (KB) article Q234067 "HOWTO: Prevent Caching in Internet Explorer" for more information about these HTTP headers.

If the above solution does not work, you can leverage the session cookies' functionality to ensure that the page is always pulled from the server. To demonstrate, we've included some sample Active Server Pages (ASP) code.

<% @LANGUAGE=JavaScript %>
<% Response.buffer = true %>
<% Response.AddHeader("Set-Cookie","FromValue=Server")%>
<HTML>
<HEAD>
</HEAD>
<BODY>
<H3>This is a test for documents being pulled from the cache</H3>
<P></P>
<A HREF="http://www.microsoft.com"> Click here to go to a different page, 
then use the Back button to come back to this page.</A>
<SCRIPT LANGUAGE=javascript>
function winload()
{
 var aCookie = document.cookie.split(";");
 var value;
 for (var i=0; i < aCookie.length; i++)   
 {
      // a name/value pair (a crumb) is separated by an equals sign
      var aCrumb = aCookie[i].split("=");
      if (aCrumb[0] == "FromValue") {
   value = unescape(aCrumb[1]);
   break;
      }
 }
 alert("Cookie: FromValue = " + value);
 if ((value != null) && (value == "Cache"))
 {
     alert("Reloading from server ... ");
     location.reload(true);
 }
}

function winunload()
{
     var val = "Cache";
     document.cookie = "FromValue=" + escape(val) + ";";
}
window.onload = winload;
window.onunload = winunload;
</SCRIPT>
</BODY>
</HTML>

Also, refer to the KB article Q199805 "PRB: Forward and Back Button Behavior in Internet Explorer" for more information regarding the Forward/Back button behavior in Internet Explorer.

The Web Team in Short

Our very first:

Q: Justin Young asks how servers connect to the Internet.

A: Check Mary Haggard's second For Starters column, Get Your Server Here!.

Ah yes, something we still have to deal with—some things never change

Q: Nelson Emilio asks how to use Active Server Pages to show first-time visitors a special "first-time" page.

A: Use cookies. Check our archived question Bake a Batch about cookies and using them with Active Server Pages.

Tom's favorite shorts (You sure you want to look?)

Q: Deborah Rhoads wants to build a search engine.

A: Refer to Microsoft Windows NT Server Web Services for complete information on Microsoft Index Server.

Q: Sophia needs more documentation and samples for building a software update channel.

A: See the December 1997 Microsoft Internet Developer magazine feature Cutting Edge: Application Channel Format.

Don't forget the KB!

Q: Jaka is trying to insert a line break in the body of a message when using the mailto URL <A HREF="mailto:someone@nowhere.com?subject=Hello&body=line%20one%0D%0Anew%20line">Drop us a line</A>.

A: Escape the % in the carriage return and line feed characters to %25. Refer to Q251230 for more information.

Or the Workshop!

Q: Jaslyn wants to provide tooltips for individual items in a list box or drop-down list.

A: The OPTION element does not fire an onmouseover event, so there is no way to determine which item you are over.


  
Show: