views:

52

answers:

2

Hello;

Thans for your help.

Please let me know that:

How can i prevent that users browse my site with a specific browser?

Thanks Ali

A: 

Using i.e. jQuery, you could detect user's browser and redirect him to 'Sorry, this browser is not supported' page as follow:

if($.browser.msie)
{
  document.location.href = "sorry.html";
}

This will work as long as user has javascript turned on. But this is not appropriate solution... good website should work correctly on all major browsers.

rochal
+6  A: 

Short answer: you can't.

Browsers will supply a user-agent header with each HTTP request, and you can use that to determine which browser a request says it is from. But the browser is often lying. In part because of developers (like you?) who try to restrict their sites to certain browsers, many browsers and users "spoof" the user-agent string, or include names of browsers they are not within that string.

If your specific concern is preventing Javascript compatibility problems, a much better approach is checking for a given piece of functionality (in Javascript) before using that functionality. This will work across browser types.

JacobM