-3

I'm developing a business websites, on which certain Javascripts and HTML work with Firefox only. How can I force user to not use other browser, something like when they open the site on Chrome, IE or Opera, they will receive a message and will be redirected to an info page.

FYI, the language I used is ASP.NET Web Form.

Edited: The solution has more than 200 pages, so I think I'll put it in a Masterpage

Edit 2: Javascript or Server script is ok

Edit 3: Reason: I'm using a third-party HTML control library. That library's DataGrid is used intensively. On the DataGrid, I always have some hidden columns and this works well with Firefox. But on Chrome, the hidden columns are exposed. Since there is no fix and I'm not ready to upgrade the library, I would like to ban other browsers as an immediate measure

Thank you

Hoang Lam
  • 326
  • 1
  • 6
  • 23
  • 2
    Didn't you tried to search for it, seriously?! – A. Wolff Mar 13 '14 at 17:17
  • Use modernizr, you will thank me later. – Zach Spencer Mar 13 '14 at 17:17
  • 1
    Have you thought about this another way: maybe you should update your JavaScript and HTML to be cross platform compatible? I usually find that if I did something that isn't cross-platform, it's a "kludge" and it's difficult to support. – mason Mar 13 '14 at 17:20
  • Your best bet is going to be checking the user agent on the server side since users can disable Javascript. Is this an internal or external site? If it's internal, your policy should be "this is the standard browser." If it's external, this is probably a bad idea. (I really haven't seen a browser-specific page since the late 1990s) – Tim Mar 13 '14 at 17:21
  • The problem is that I put "Javascript" in the title. Sorry for that, because my user sometimes turn off Javascript. So apart from Javascript, is there anything else ? @Tim: it's an internal site, with sensitive information – Hoang Lam Mar 13 '14 at 17:21
  • @HoangLam sensitive informations have to be only on server, i really don't see why then user should only use FF – A. Wolff Mar 13 '14 at 17:30
  • @A.Wolff, I'm using a third-party HTML control library. That library's DataGrid is used intensively. On some DataGrid, I hide certain data-bound columns and this works well with Firefox. But on Chrome, the hidden columns are exposed. Since there is no fix and I'm not ready to upgrade the library, I would like to ban other browser as an immediate measure – Hoang Lam Mar 13 '14 at 17:34
  • I will answer as not a duplicate since the question is how to 'force' a requester to use a specific browser and not just browser detection. – David H. Bennett Mar 13 '14 at 17:42
  • Can your IT department just make the policy you support Firefox and not even bother with code? If it's internal, you should be able to make that kind of policy decision. – Tim Mar 13 '14 at 17:50

3 Answers3

0

what you want is identifying browser : How to detect Safari, Chrome, IE, Firefox and Opera browser? they will need javascript turned on though

  • So forget about JS, can we modify global.asax ? – Hoang Lam Mar 13 '14 at 17:20
  • You could check the User-Agent request header in the Global.Asax for Firefox and send back a 403 http status for browsers that aren't FireFox. What the other people said though: don't get comfortable with this solution – Menno van den Heuvel Mar 13 '14 at 19:40
0

In your master page header put:

 if(typeof InstallTrigger == 'undefined')
   alert('Please use firefox');
   // and whatever else like a redirect or something..
JF it
  • 2,325
  • 3
  • 17
  • 28
0

You can use the 'sayswho' script referenced in DontVoteMeDown's comment above along with a confirm() call.

if (!navigator.sayswho.match(/^.*firefox.*$/i)) {
  if (confirm("This site is optimized for Firefox,  it may not work with your browser.  Do you want to download Firefox now?"))
  {
    document.location="http://www.mozilla.org/en-US/firefox/new/";
  } else {
    // go someplace else or let them use at their own risk
  }
} 
Community
  • 1
  • 1
David H. Bennett
  • 1,742
  • 12
  • 16