onMouseOver Event ![]()
|
Avoiding JavaScript Errors on Earlier Browsers While this script was never intended to work on browsers earlier than version 4 and it’s probably safe to assume that few are using them anymore, it’s always best to avoid JavaScript errors in the event that someone may actually view a web page exploiting later version JavaScript capabilities. The standard method for doing is to include the JavaScript version number in the <SCRIPT> tag, such as:
which works well where the script code is enclosed between the <SCRIPT></SCRIPT> tags. However, if one wants to use a script library reference using the src attribute of the <SCRIPT> tag, such as:
then the language version is ignored and the script library code is loaded anyway. Since this code contains many non-version 3 JavaScript statements, it will report errors when viewed on version 3 browsers. At first glance, this seems to present a least-worst scenario. Either accept that version 3 browsers will report script errors and use the convenience and maintainability of a library load using the src attribute or embed the entire script between the <SCRIPT language="JavaScript1.2"></SCRIPT> tags on every web page the function will be used. Given only those two choices, the former one would be the least-worst option but hardly a preferred one. Thankfully, there is a way around this dilemma that simply involves the use of the JavaScript document.write() method. Below is a script scrap demonstrating this workaround:
Note: Be sure to escape any slashes within the write string, e.g., <\/SCRIPT>. The JavaScript version in the language attribute of the <SCRIPT> prevents version 3 browsers from processing the enclosed script and the enclosed document.write() method essentially includes a <SCRIPT> tag in the document that does the JavaScript library load. Note: It has the added benefit of hiding the script source on browser when viewed using the View Page Source menu selection.
YAMF - "Yet Another Mouse Follower" All Is Not What It Seems Netscape 6 Made Me Do It! Testing - To Reload or To Restart? Browser Sniffing - Parse or Presence? Avoiding JavaScript Errors on Earlier Browsers Stopping Annoying Auto-Scroll in DOM2 Browsers Netscape 6 is Pixel Picky Inline Style Constraint on Internet Explorer 5 Must Use <LAYER> tag in Netscape 4 to perform DHTML !DOCTYPE Compliance Mode Take Care Not to Render in <HEAD> Section Automatic Expansion of Relative URLs The Elusive Netscape 4 Layer Elements Temperamental onLoad After Reload document.images[id].complete Property Dependency Search Method Does Not Return Boolean Value Regular Expression Global Flag Fails With Subsequent Usage Conclusion Resources Downloads Roll Your Own |
onMouseOver Event ![]()
|
|||||||||||
onMouseOver Event ![]()
|
onMouseOver Event ![]()
|
Copyright © 2002-2003, ProjectIt, All Rights Reserved | Last Revised: |