A DOM1/DOM2 DHTML JavaScript Experiment

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

  

Search Method Does Not Return Boolean Value

According to the JavaScript documentation, the Regular Expression string search method returns either a boolean true of false value depending on a match being found. However, what is really returned is either the character position in the string where a match was found or a -1 if a match was not found. Thus, any JavaScript code expecting a boolean value return should instead use the Regular Expression string test method. Below is an example that should help illustrate this:

  if (string.search(re))
    do something;	// Always gets executed
  else
    do something else;	// Never gets executed


  if (re.test(string))
    do something;	// Executed if string match
  else
    do something else;	// Executed if no string match

Regular Expression Global Flag Fails With Subsequent Usage

In both Netscape 4/6, the use of the global flag in a Regular Expression causes it to fail on subsequent usage. This is not a problem with Internet Explorer 5/6. For example, /abc/gi.exec("xxabcxx") succeeds the first time it’s used but fails if the same Regular Expression is used later, e.g., /abc/gi.exec("yyabcyy"). There does not appear to be a problem with the ignore flag.

A workaround is to use the Regular Expression constructor function and the compile method. This adds some overhead but it does work in all browsers. Below is an example of how this can be done.

function getRE(EXP) {
  var re = new RegExp();
  return re.compile(EXP, "gi");
}
  getRE("abc").exec("xxabcxx");
  getRE("abc").exec("yyabcyy");

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=false
Effect=dither
Direction=left
Angle=135.0
Scale=1.0
YGapAdj=0
IPrefix=yamf
Reverse=false
YAMF OFF!

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

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

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