Select Categories Below
Status: Open Points: 125 Time: 06:33 - Jun 14, 2007
neerusaini
How to Identify the browser using java script (for IE/Safari/Firefox)
Categories:
Add Categories
When adding more than one category, separate them with commas.
Advertisement
euzuro
Date:: Jun 14, 2007
Time:: 08:36
/** * @returns A string which specifies which is the current * browser in which we are running. * * Currently-supported browser detection and codes: * * 'opera' -- Opera * * 'msie' -- Internet Explorer * * 'safari' -- Safari * * 'firefox' -- FireFox * * 'mozilla' -- Mozilla * * If we are unable to property identify the browser, we * return an empty string. * * @type String */ OpenLayers.Util.getBrowserName = function() { var browserName = ""; var ua = navigator.userAgent.toLowerCase(); if ( ua.indexOf( "opera" ) != -1 ) { browserName = "opera"; } else if ( ua.indexOf( "msie" ) != -1 ) { browserName = "msie"; } else if ( ua.indexOf( "safari" ) != -1 ) { browserName = "safari"; } else if ( ua.indexOf( "mozilla" ) != -1 ) { if ( ua.indexOf( "firefox" ) != -1 ) { browserName = "firefox"; } else { browserName = "mozilla"; } } return browserName; };
nidhi
Time:: 17:42
For info only, this is old skool, useful really only if you wanted to check for IE Before it was possible to use appName, but both Mozilla and Safari both return Netscape which is why you cant really use it now. the navigator object is a throwback from Netscape Navigator days I believe hence the use of that keyword. simple test I used. This is for information only, it is not something you should be using. As I said before, only handy if you want to check for MSIE only. <HTML> <head> <script language="javascript"> function tellmemybrowser() { alert(navigator.appName); } </script> </head> <BODY onload="tellmemybrowser();"> Yo </BODY> </HTML> So your best bet to identify individual browsers nowadays is to use userAgent and which euzuro has given you the answer to your question. You can use the navigator object to determine other things as well like version (use indexOf) and os. A sample function can be found here http://www.quirksmode.org/js/detect.html
xarcus
Date:: Jun 16, 2007
Time:: 05:45
MSIE, Opera, Konqueror, Safari, Netscape, Gecko based Two versions simple and full featured http://techpatterns.com/downloads/javasc...
admin
Date:: Aug 22, 2007
Time:: 13:25
neerusaini, did you get your question solved? If you did then please close this question and distribute the points. If you found the solution on your own, we would be very happy if you could explain it here for the sake other users having the same problem. If you didn't get a solution to your problem, please leave a comment here to let the experts know that you're still looking for an answer. Thanks, The Quomon Admin Team
shashi.programmer
Date:: Sep 27, 2007
Time:: 04:08
try to check this http://www.mistered.us/tips/javascript/b...
Ramasamy.N
Date:: Oct 12, 2007
Time:: 05:59
navigator.appName
prashanth.guru
Date:: Oct 18, 2007
Time:: 06:15
http://www.javascriptkit.com/javatutors/... The above link helps allot on your question. Thanks, Prash
Answer this Question
New User
Email:
Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address
Registered User
Username:
Password:
Forgot Your Password?
Enter your email address below and we will resend your login information to you.
Login Information Sent
Questions
hover gallery.
How long does Google and MSN store emails that can...
Does the United States Government have a CIO posit...
How do you turn off the signature option in the ad...
audio quality- when playing music/video's, the sou...
Thanks for your reply. Where are you located? Whic...
You have 100 characters to use
Rank
Expert
Points
1.
215
2.
125
3.
4.
30
5.
25
6.
5
Register today to share your knowledge with the community and be recognized and rewarded for your contributions.
Register Here
"Psst, Quomon is a great site. Pass it on." Tell a Friend | Link To Us | Save to Delicious | Digg it
Language Options
English:
Español:
Sponsors
Questions and Answers Software Real Estate Postcards Marketing Fulfillment