Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

What You Want, When You Want It

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 and Rafael M. Muñoz
Microsoft Corporation

August 7, 2000

We're big fans of specifics. If you need this and only this, or you want that to go away, we're here to help. This month, Web Team members Heidi and Rafael address some Web development particulars: how to close a program and how to validate text box entries—plus some of the finer points of linking when it comes to pop-up windows and e-mail.


Shoo, Excel, don't bother me—JScript not removing Excel processes
Popping around—Using the Internet Explorer 5.5 PopUp feature
You're missing the point, er, subject—A common Mailto: protocol mistake
Getting real numbers—Text-box entry validation

The Web Team in Short

Shoo, Excel, Don't Bother Me

Dear Web Team:

I have script on a Web page that creates an Excel sheet and then saves it. This all works great—but upon further investigation, I am noticing that the actual Excel process has not terminated per the task manager. Please make it go away!

Sample of my code:

function CreateXlsDoc() {
   var xlsApp;
   var xlsSheet;
   // create application and add a workbook
   xlsApp = new ActiveXObject("Excel.Application");
   xlsApp.Visible = true;
   // write some text, save the file
   xlsSheet = xlsApp.ActiveSheet;
   xlsSheet.Cells(1,1).Value = "The Web Team is cool";
   // clean up
   xlsSheet = "";
   xlsApp = "";

Kenny J. O'Connell

The Web Team replies:

Don't you just hate those pesky applications that hang around after the party is over? Kenny, what you are experiencing is, by design, due to the fact that JScript is a garbage-collected language.

A lot of complicated magic goes along with the garbage-collection algorithms. The JScript scripting engine will clean up after itself when it reaches a certain point; just assigning an object to null/nothing won't do the trick. The engine will also clean up after itself when the browser is shut down. You've probably noticed that the Excel process goes away upon closing the browser.

VBScript, on the other hand, actually frees a reference to an object when you set it to nothing. That said, we took the liberty of modifying your code slightly, and we rewrote your function in VBScript. If you run your tests now, you'll notice that after you set xlsApp to nothing, the Excel process goes away without requiring you to close the browser.

sub CreateXlsDoc()
   dim xlsApp
   dim xlsSheet
   ' create application and add a workbook
   set xlsApp = CreateObject("Excel.Application")
   xlsApp.Visible = true xlsApp.Workbooks.Add
   ' write some text, save the file
   set xlsSheet = xlsApp.ActiveSheet
   xlsSheet.Cells(1,1).Value = "The Web Team is cool"
   ' clean up xlsSheet = ""
   xlsApp = ""
end sub

Popping Around

Dear Web Team:

I just got Internet Explorer 5.5, and I have been playing with some of the new features. I especially like the idea of the PopUp, but how do you make it work? I can make a pop-up window come up, and put content in it. The only problem is that I can't get any events to work, like the onclick event, or any other scripts. And even when you use the <A HREF=""> tag, it does not work; when you click on the link, it does nothing. How are you supposed to use PopUp to make menus or dialog boxes (which another article suggests as ways of making use of this command) if you can't do any of those things.

Please help me!


The Web Team replies:

The PopUp feature itself can't navigate, but you can get the parentWindow to navigate by assigning a function in the parent window to the onclick event of the pop-up window.

We've put together a little sample to illustrate handling the onclick event of the PopUp feature and navigating the main window to the link clicked on in the pop-up window.

<TITLE>Popup Navigation</TITLE>
<BODY BGCOLOR=lightyellow>
      function clickPopup(){
         var srcElem = oPopup.document.parentWindow.event.srcElement;
         if (srcElem.tagName == "A") {

      function displayPopup () {
         oPopup.show(90,1, 60, 40, popspan);

      var oPopup = window.createPopup();
      var popupBody = oPopup.document.body;

      navLinks = "<A HREF=\"http://msdn.microsoft.com\">MSDN</A><BR>"
      navLinks += "<A HREF=\"http://msdn.microsoft.com/voices\">Voices</A>"
      popupBody.innerHTML = navLinks;

      oPopup.document.body.onclick = clickPopup;


<SPAN ID=popspan ONCLICK="displayPopup();">show navbar</SPAN>


You're Missing the Point, er, Subject

Dear Web Team:


I am trying to use the Mailto protocol to create an e-mail that adds the e-mail address, subject, and some body text already filled in, as below:

<A HREF="mailto:me@here.com&subject=Feedback&body=The%20web%20site%20is%20superlative">
Click Here to send your feedback to Me.</A>

However, this puts all of the data into the address line and does not place it in the relevant section of the e-mail. I am using Internet Explorer 5.00.2314.1003CO and Microsoft Outlook 97 (8.01.3817). Any ideas on what I am doing wrong?


Andrew Wright

The Web Team replies:

Andrew, we know you are not going to believe this—but we were actually discussing this exact issue with our editor the other day. Have you tried testing your HTML with Outlook 2000? If you had, you would have noticed that it works—not to say that it's right, yet.

You are making a common mistake when using the Mailto protocol: You are using the "&" character in front of the subject, instead of the necessary "?". If you had been testing with Outlook 2000, you would never have known you had a problem—at least not until your customers complained. For some reason, Outlook 2000 is being a little more lenient. Now, if you ran those same tests with Outlook Express, you would get the same results that you are seeing with Outlook 97.

By making the change shown here, you should get everything right where you expect it:

<A HREF="mailto:me@here.com?subject=Feedback&body=The%20web%20site%20is%20superlative">Click Here to send your feedback to Me.</A>

Refer to MSDN Online for more information on the Mailto Protocol and its syntax.

Getting Real Numbers

Dear Web Team:

Hello, Team.

I have created a simple Web page with a text box on it. I would like the user to enter only numeric values in this text box. So each time on a key press, I would like to validate the character entered. So if a number is typed, then fine; otherwise, I don't want non-numeric values to be entered. I am using Visual InterDev as my HTML editor. I need to know the JavaScript in order to carry out the client-side validation.



The Web Team replies:

The following sample shows how to check input as the user enters it, and how to keep the input from displaying in the text box if it fails the test. In this case, we are looking for digits.

<HEAD><TITLE>Input Validation</TITLE>
function checkKey()
   if ( window.event.keyCode > 57 | window.event.keyCode < 48)
      alert("Please enter only digits in this box")
<P>Please enter only digits in this box.<BR>
    <INPUT TYPE=text NAME=txtEnterValue onkeypress="checkKey()">


If window.event.returnValue is set to false, the character will not be entered into the text box. You can check the status of things like the event key. Check the event object in the DHTML References section.

Another great way to validate client entry is by using regular expressions. The October 1998 issue of MIND (now MSDN Magazine) included the article Validation Made Simple with JScript Regular Expressions, written by one of our very own Web team members.

The regular expression object is now available in VBScript and for Visual Basic. Have a look at the Regular Expressions Guide on the Windows Script Technologies site.

The Web Team in Short

Q: We found a few questions regarding last month's sample on using the content-disposition to get Internet Explorer to open the incoming HTML in Excel. For some people, the ASP code was appearing in Excel.

A: You can get around this problem by just putting a question mark at the end of your URL: http://myexceltable.asp?. See Q266263 "BUG: Word 2000 and Excel 2000 Display ASP Source When Using MIME Type to Stream Data.".

Q: Sjaak wants to determine whether a specific instance of Internet Explorer is already open before trying to open a new window.

A: Open the second window using window.open, and save the handle that is returned from the open method. You can check to see if that variable is empty, or if the window has been closed.

Q: Muhammed Abu Laila wants to print a document programmatically from a Web page.

A: Refer to "Scripting Support for Web Page Printing."

Q: Sarah wants to maintain quote symbols when using a series of document.write statements to write out a page.

A: If you are using VBScript, use two double quotes for each double quote you need in a string. In JavaScript, protect the double quote with a backslash (\").

Q: Brendan Casey asks the ever-popular question: "How do you create that customized icon for the Favorites menu?"

A: See "How to Add a Shortcut Icon to a Web Page."

The Web Team

Heidi Housten is on the MSDN Architectural Samples team. She came to MSDN from the Internet Client team at Microsoft Developer Support. She is convinced that her 14 years of living and working in England were just preparation for the gray and drizzle of Seattle.

Rafael M. Muñoz, when not playing or coaching his favorite pastime (volleyball), provides technical assistance as a full-time developer support engineer for Microsoft Developer Support.

Thomas Moran, when not struggling to maintain some semblance of sanity (working with Rafael certainly doesn't help), toils with a prodigious team that creates articles and other content from Microsoft's Developer Support.

Kusuma Vellanki is one of the few people who like winters in Washington state more than summers. When not working as a Developer Support Engineer for the Internet Client team, she can be found torpedoing out of control down the ski slopes.

© 2015 Microsoft