So, if you have modified a script and are pulling your hair out because it should be working and isnít, before going for your .45, try exiting and restarting the browser. It may save your sanity and, at minimum, it should save you ammo and a monitor or two.
There are a number of excellent browser sniffer scripts out there that basically parse the strings returned from the navigator.appName and navigator.appVersion properties and return various boolean variables that provides the developer precise information about which browser the client is using. From these, the script can make decisions as to how to proceed to get whatever function is being performed to work on said client browser. There is also an alternative to this approach that basically uses the existence of properties and objects to determine the client browserís capabilities. YAMF uses the latter approach since the testing for the existence of properties is less error-prone (in the case of subsequent browser version changes) and is certainly a lot less complex to determine. Also, as an added benefit, the flags really represent object and property capabilities rather than specific browser versions so the script is much more likely to continue to work in later versions of browsers, assuming they donít go around "deprecating" the newer DOM2 objects and properties in the future.
Below is the script used to set the relevant browser boolean flags:
Note: the order in which the above statements are written is important due to dependence on previously set flags in determining subsequent flags, e.g., isIE must be set first since it is used in many subsequent statements. YAMF only uses a few of the booleans above but Iíve included them all since I use this script scrap for other scripting designs.
Lastly, no attempt is made to accommodate Netscape or Internet Explorer browsers earlier than version 3 since its probably safe to assume that those are no longer in use. Also, the testing environment for this script was Windows 98SE and only Netscape 3/4/6 and Internet Explorer 5/6 browsers. Caveat: Opera 6.05 was tested but failed to even display the images.
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?
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
Roll Your Own
|Copyright © 2002-2003, ProjectIt, All Rights Reserved