This article may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. To maintain the flow of the article, we've left these URLs in the text, but disabled the links.


MIND


GEEK

geekgeek@microsoft.com        Download the code (3KB)

Robert Hess


GEEK You previously mentioned that to size input boxes you should use the   string inside the value property. This is actually only half correct. I know that you focus on Microsoft® Internet Explorer, but a large portion of users still have Netscape browsers. Because the default fonts used in forms are different in Internet Explorer and Netscape Navigator, the spacing you specified between the two browsers is not identical. The cheap and dirty way around this is to employ Cascading Style Sheets (CSS) for Internet Explorer and change the font property to NewCourier 10 point for all INPUT attributes. Now you can use   inside the value property and all buttons will be the same size.
GEEK If you'll read the question again, you'll note that the question and my answer specifically deal with Netscape Navigator since the person asking the question already had a workable solution for Internet Explorer. So I was most definitely paying attention to the needs of Navigator users!
      The original question also only asked how to affect the size of buttons, not how to make multiple buttons the same size (although it is not a stretch of the imagination to see that as the next step). Your additional solution of using CSS provides a mechanism of getting more uniform sizes on the buttons. It also suffers from two problems: Navigator 3.x doesn't support CSS, and Navigator 4.x is still too new a product to accurately judge its customer base.

GEEK I'm running Windows NT® 4.0 and IIS 3.0. When I try to run ASP files, Internet Explorer 3.02 tells me "Access Forbidden (Read Access Denied—This virtual directory does not allow objects to be read)." The ASP files I am trying to execute are in a directory that has execute access but not read access. It's like IIS is trying to read the file when it should be executing it. Why is this? I looked at the file types option in the Control Panel and ASP is not listed as a file type. But if I type it in as a new file type, it tells me "The extension ASP is already in use by file type asp_auto_file. Choose another extension."
GEEK There are two different ways to set privileges on your Web files. You can set them for the Windows NT system itself via Explorer (right-click on the file or subdirectory, select Properties, then select Permissions). You can also assign them from IIS, which allows you to set either read or execute privileges. For ASP files, the system (Explorer) settings need to include read or else the ASP parser won't be able to open the script and read it. The IIS settings can be set to execute, which will allow the scripts in that subdirectory to be executed while preventing people from accessing other files in that directory for reading.

GEEK I have a page that incorporates VBScript. I want to use the same code on multiple pages, but I can't get it to work. Internet Explorer says that chcolor.style isn't supported. Why can't I have the same ID twice? Here's the code:

 <script language="vbscript">
 SUB chcolor_onmouseover
    chcolor.style.color = "red"
 END SUB
 
 SUB chcolor_onmouseout
    chcolor.style.color = "#6E461E"
 END SUB
 </script>
This is what I want to do:
 <body>
 <font size="6" face="nadianne" color "#6e461e">
 <p><a id="chcolor" href="html/11.html" target="_top">text1</a></p>
 <p><a id="chcolor" href="html/12.html" target="_top">text2</a></p>
 </font>
 </body>
GEEK You are attempting to give several different elements on your page the same ID. Based on your code, I suspect that you want to have one function that services the onmouseover event for multiple elements on the page. Figure 1 shows a much better way of accomplishing this.
      Note that this is not the only way to achieve what you were trying, just the one that is probably closest in structure to the sample code you sent me. You could also use what is known as event bubbling to do the same thing, which would be especially handy if you simply wanted all anchors on the page to have a mouseover effect. Figure 2 shows an example of what that code might look like. While this appears to have more code in it, note that the <script> block is written so that it is simply copied over into any file you want this behavior in, making other changes unnecessary.

GEEK How can I configure Personal Web Server so I can view and create ASP files? I downloaded ASP and installed it into the Scripts folder, then changed the permissions on the folder to read and execute scripts. But when I click on an ASP file, FrontPage® opens up. What am I doing wrong?
GEEK The problem you are having is sort of a conceptual one. ASP is something that is connected to file/data transfer via the HTTP protocol. When you double-click an ASP file from within Internet Explorer, you're just opening it as a file—Personal Web Server isn't coming into the picture at all. FrontPage has registered itself with the operating system as the default handler of files that have an extension of .asp, so this is what comes up when you double-click on an ASP file.

GEEK I wrote a JavaScript version of your "select and go" dropdown list from the August 1997 issue of MIND. It works fine in Internet Explorer 4.0, but has problems in Navigator 3.x and Internet Explorer 3.x.


 <HTML>
 <BODY>
 <FORM>
 <SELECT onChange="launch(this.value)">
 <OPTION>
 <OPTION VALUE="one.html">One
 <OPTION VALUE="two.html">Two
 <OPTION VALUE="three.html">Three
 </SELECT>
 </FORM>
 <script language="javascript">
 <!—
   function launch(selvalue)
   {
     location.href = selvalue
   }
 —>
 </script>
 </BODY>
 </HTML>
GEEK You are having trouble because you didn't convert the code from VBScript to JavaScript properly. While Internet Explorer 4.0 is being nice by recognizing this value, and is attempting to reference the currently selected value of the <select> element, both Internet Explorer 3.x and Navigator 3.x are being a little more hardnosed about this. Both require you to specifically identify the value you want to access as an indexed offset into the full array of options contained in the select array. If you recall my original VBScript code, I got this value as follows:

 <select onChange="Launch(this)">
 ...
 <script language="vbscript">
 sub Launch(this)
 window.location.href = this.options(this.selectedIndex).value
 end sub
 </script>
And so a correct translation of this to JavaScript would be:

 <select onChange="launch(this)">
 ...
 <script language="javascript">
 function launch(selvalue)
 {
 location.href = (selvalue.options[selvalue.selectedIndex].value);
 }
 </script>

GEEK What is a good resource for do's and don'ts to achieve cross-browser compatibility?
GEEK The best resource is probably the HTML 2.0 specification. If you follow it to the letter, your pages should be compatible across the bulk of browsers out there. Of course, you probably want to utilize some of the more advanced features that browsers expose. The next suggestion would be the HTML 3.2 specification, which includes many of the added HTML features that browsers have been implementing. If what you're really after is something that gets down to the bare metal of the various browsers, carefully examines all of their various capabilities, and shows you how to create code that utilizes these high-powered features in a fully compatible fashion, then the best location for information comes from the School Of Hard Knocks.
      I have never seen a book that addresses these issues properly, and for good reason. The permutations and levels of complexity are so great that the book would either have to be a massive concordance of information or it would have to only touch on a small subset of information. Add the fact that browsers are evolving so quickly that the book would be out of date by the time it reached the shelves.
       One of the important things to realize is that when your page design starts to bump into serious compatibility issues, then you are most likely combining the various features that the browsers support in ways that are comparatively unique to your situation. I've found that the best way to work around these problems is to simply start hacking around in the code of your page. If you try to rely on outside sources for recipes on how to design your pages, then you give up much of the understanding of what you are doing.

From the March 1998 issue of Microsoft Interactive Developer.