Click here to Skip to main content
15,884,783 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is there a fairly easy way to detect what browsers a user has on their computer? (eg: IE, Chrome, Firefox, Safari, Opera...) I would imagine that you would look in the Registry for part of the process... any other places I would look?
Posted

Executable files can be placed anywhere, so searching in Program Files is probably not going to work all the time. And the registry is iffy: even if you know where major browsers currently store data, there is no guarantee that future versions will put data in the same location, or that browsers not on your find list are in the same vicinity, or even that the the browser is still installed.

So no. To the best of my knowledge, the closest you could get would be to try opening an .html file and try to catch the user's default browser. Assuming they haven't changed it (accidentally or deliberately) to something like Notepad.
 
Share this answer
 
Comments
drummerboy0511 1-Mar-11 11:39am    
Thanks for the heads-up; I knew the Program Files thing wouldn't work. I could probably do a search for "firefox.exe," but who's to say that would work?

I could probably just detect the fairly recent versions of the browser in the Registry, and update it as necessary, I guess. It's a small fix, for now at least...
Sergey Alexandrovich Kryukov 1-Mar-11 12:07pm    
Your first paragraph is correct, but last paragraph makes no sense. Default browser does not matter in any case, because nothing prevents the user to run non-default one. OP wants to know "Browsers" not "Browser". I argue it makes no sense though, please see my Answer.
--SA
You cannot do it in principle in any sensible way, simply because the very notion "a user has" is something uncertain. A browser, like any other application can work even if it is not installed. The user can run anything from, say, flash drive at any moment. Most likely, it also makes no sense.

You Web application is different story; you can always get some information in the Browser in both client and server parts. Of course, one browser can mimic another one (and some do).

If you share your idea, why you want it, you could get better advice. I think your problem is in this idea.

—SA
 
Share this answer
 
Comments
drummerboy0511 1-Mar-11 12:17pm    
Okay, why I want it: Part of a program I'm writing has features that only enable if they have a certain browser. If they don't, they can't access it. So, obviously, I need to check, "Okay, do they have Firefox? Okay, then we'll get them in this part. Do they have Chrome? No? Okay, block that."
Sergey Alexandrovich Kryukov 1-Mar-11 14:21pm    
No, it doesn't explains things yet. If this is Web application, you don't have access to client's computer in principle. Is it is not, it does not matter (for example, you could use embedded browser control which is under your control, also, using Web technology in non-Web application is questionable). Even on local computer you never know what browser will be used in next minute, so your whole idea won't work (even though you did not completely explain the purpose). In all cases, the only valid browser information can be get only after a Web browser already loaded your page, not sooner.
--SA
drummerboy0511 1-Mar-11 14:33pm    
Sorry... it's a desktop application.
Sergey Alexandrovich Kryukov 1-Mar-11 14:47pm    
Ok, if this is a desktop, you don't need to know all that (especially when you can't :-).
1) You can go along without any Browser.
2) You can enforce Microsoft (or Mozilla, for that matter): embed a Windows Explorer control in your application and use it.
--SA
May be

C#
switch (Request.Browser.Browser.ToLower())
{
    case "ie":
       ..
       // your code for IE
       ..
    break;
    case "firefox":
       ..
       // your code for Firefox
       ..
    break;
    default:
       ..
       // default code for other browsers
       ..
    break;
}



is what you are looking for.



Please vote and mark as answer if this helps you


 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900