Select Categories Below
Advertisement
Start Your Own Q&A Site
Create your own Q&A site easily, allowing you to quickly grow a new community around any subject matter or generate new organic traffic for your existing website.
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.
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
mikkelnh
Date:: Mar 17, 2011
Time:: 10:38
nice browser and OS detect script here i use it myself and it works gr8 http://fatkid.dk/Article/Articel/9
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
Hi is there a way to retrieve the loop count in XSLT
how do repair this problem: every times i opened my laptop it will suddenly n...
How i get the hp pavilion dv6-3054tx laptop bottom base assembly as a sparepa...
I don't have AOL browser but privacy scan shows hundreds of files/cookies fro...
wireless keyboard has stopped working
need validation controller for textbox in java
You have 100 characters to use
Rank
Expert
Points
1.
10279
2.
6493
3.
5596
4.
4848
5.
3487
6.
2840
7.
2770
8.
2303
9.
1820
10.
917
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