A DOM1/DOM2 DHTML JavaScript Experiment

YAMF
onMouseOver Event
Type=banner
Justify=left
View=visible
Rate=50
XGapAdj=0
IPath=images/
IExt=gif
angAware=true
Effect=rotate
Direction=right
Angle=0.0
Scale=1.0
YGapAdj=0
IPrefix=yamf
Reverse=false
YAMF OFF!

  

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:

<script language="JavaScript1.2">

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:

<script language="JavaScript1.2" src="jslib/yamf12.js">

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:

<script>
<!--
  function YAMF() {
    return false;
  }
//-->
</script>

<script language="JavaScript1.2">
<!--
  document.write("<script src='jslib/yamf12.js'><\/script>");
//-->
</script>

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.

PreviousNext


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
  
YAMF
onMouseOver Event
Type=banner
Justify=center
View=visible
Rate=50
XGapAdj=0
IPath=images/
IExt=gif
angAware=true
Effect=rotate
Direction=right
Angle=0.0
Scale=1.0
YGapAdj=0
IPrefix=yamf
Reverse=false
YAMF OFF!

YAMF
onMouseOver Event
Type=banner
Justify=right
View=visible
Rate=50
XGapAdj=0
IPath=images/
IExt=gif
angAware=true
Effect=marquee
Direction=right
Angle=0.0
Scale=1.0
YGapAdj=0
IPrefix=yamf
Reverse=false
YAMF OFF!

YAMF
onMouseOver Event
Type=banner
Justify=left
View=visible
Rate=50
XGapAdj=0
IPath=images/
IExt=gif
angAware=true
Effect=marquee
Direction=right
Angle=0.0
Scale=1.0
YGapAdj=0
IPrefix=yamf
Reverse=false
YAMF OFF!

Copyright © 2002-2003, ProjectIt, All Rights Reserved Last Revised: