However, JavaScript suffers from the same problems as Java
<script language="JavaScript"> <!-- your code goes here //--> </script> <NOSCRIPT> This is where you place what you want shown if the script is disabled. Does not work in IE 4.72 </NOSCRIPT>
Code Examples
The location object (or perhaps its window.location?) is not documented in the Microsoft JScript reference
This basically works in both browsers (except that the arrow keys, et al. are different)
Get Keystrokes
Netscape | keyStroke.which | |
IE | event.keyCode |
// Cross-browser key capture routine couresty // of Randy Bennett (rbennett@thezone.net) isNetscape = (document.layers); eventChooser = (isNetscape) ? keyStroke.which : event.keyCode;
Determine The Browser Flavor
var bFlavor; // Browser Flavor var bName=navigator.appName; var bVer=parseInt(navigator.appVersion); if(bName=="Netscape" && bVer>2) bFlavor = "net+"; else if(bName=="Netscape" && bVer<=2) bFlavor = "net2"; else if(bName=="Microsoft Internet Explorer" && bVer>=4) bFlavor = "IE4+"; else bFlavor = "IE3";
Dynamic Menus
Here is an explanation and example which works in IE 4.72, IE 5.0, and Netscape Communicator 4.05.
Document Date
Browser | Day | Month+1/Date/Year | document.lastModified | |||
---|---|---|---|---|---|---|
This Browser | ||||||
IE 4.72 | 3 | 1/30/1 | 01/30/01 01:06:14 | |||
IE 5 | 1 | 1/29/2001 | 01/29/2001 20:24:42 | |||
Netscape 4.01a | 2 | 1/29/1 | 01/29/01 20:26:00 | |||
Netscape 4.05 | 2 | 1/29/1 | 01/29/01 20:08:44 | |||
Netscape 4.75 | 1 | 1/29/101 | Monday, January 29, 2001 20:26:04 |
Speaking of dates, here is a cool trick. By typing
javascript:alert(document.lastModified)into the browser's address bar, you can determine the date that the current page was modified. It takes a little finagling, but this link can also be placed in the IE favorites - after you add a new favorite, right click it, select Properties, and change the URL to the command above. Then simply drag the selection to the top of the menu.
Caution: Some files do not indicate the date they were last modified. As a result, the date reported by document.lastModified is browser dependent. For example
Browser | Date Reported | |
---|---|---|
IE 5.0 | Today's date | |
Netscape 4.7 | Dec. 31, 1969 |
This behavior should be expected for cgi and asp files (their content is generated when the page is requested), but other files may also omit the date modified.
The actual dates sent to Internet Explorer can be checked by viewing
C:\WINDOWS\Temporary Internet Filesand sorting by Date Last Accessed. (The actual path is OS dependent.) This may also allow you to see when each image (jpeg) was last modified. (For my files, the date reported is when the file was FTP'ed to the server, NOT the date the file was last modified.)
Warning
JavaScript 1.3 contains an ECMA-compliant fix regarding assignments such that if (a=b) is no longer interpreted as if (a==b). You can update the code or, if you want the old behavior, specify <SCRIPT language="JavaScript1.2">.