Link to home
Start Free TrialLog in
Avatar of Bernard Savonet
Bernard SavonetFlag for France

asked on

Javascript test for Mozilla Firefox or Microsoft Internet Explorer IE

This is probably a great classic... but I can't find where it is here...

Working with javascript, I need to know if the page is running under Internet Explorer or Firefox: I will then load scripts and libraries accordingly.

It is just some dumb debugging code that will differ between versions, I do not need a 200% bulletproff solution
Avatar of hongjun
hongjun
Flag of Singapore image

You can run both IE and Firefox side by side at the same time on the same machine.

hongjun
Avatar of Bernard Savonet

ASKER

Thx, I know, I do.

But I really want to run a single program that will behave differently
>>But I really want to run a single program that will behave differently

Don't understand
are you looking for something like this?

http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html

Usually you can check certain javascript element properties in your script to see if they exist which allows you to determine which methods/properties to use, instead of doing actual browser sniffing from the get go, which can unreliable when new versions are released
in my case, I just want to test if
     var fso = new ActiveXObject('Scripting.FileSystemObject');
is possible, which would allow me (under IE) to write some debug information to a file.
(Under Firefox, this just explodes but I can use more powerful debugging tools).
I simply don't want to edit 1 jd file an 1 html file every time I switch browser while debugging.

I have been trying to test if 'ActiveXObject' exists, but my test, most probably badly written, did fail.
ASKER CERTIFIED SOLUTION
Avatar of hongjun
hongjun
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Great, exactly the simple solution I was looking for. Thx
Glad I could help and apologies in failing to understand your question earlier.

hongjun