Ok, I know that it is standard practice to "sniff" out a browser, but this isn't what you really wanted to do! What you really want to know is whether or not the user's current browser is compatible with your script. It could be any browser as long as it supports the functionality your script requires.
So, the question shouldn't be: Is this IE or is this NS/FF?
Ask instead: Does this browser have document.attachEvent function or a document.addEventListener function?
(if you are using those functions, that is)
If you test for functionality you can avoid the trap of sniffing the user agent string. Besides, FF has a plugin that allows you to change the UA to match IE which fools those kind of scripts and breaks the page.
In the head section of your page:
var scriptStr = 'unknown.js';
if (typeof document.attachEvent != 'undefined') scriptStr = 'ie_compatible.js';
if (typeof document.addEventListener != 'undefined') scriptStr = 'ns_compatible.js';
/* Do not put any code here that relys on
either of the three scripts mentioned above. */
<!-- One of the above scripts will be loaded here -->
/* Now you can use code that depends on
any of the three scripts mentioned previously. */
//defined in one of the scripts (unkown.js, ie_compatible.js or ns_compatible.js)
BrowserIndependent.attachListener(myElement, myFunct, true);
Change: document.attachEvent and document.addEventListener to the functions required by the scripts they load.