0

So I have a website that doesn't work correctly in certain browsers like Firefox. I was wondering how do I make it so that when someone visits the webpage in an unsupported browser(s) it shows a message. Just like on http://species-in-pieces.com has a page that says "Works Best in Chrome. You Can Download it Here." when you're not using chrome (or something along those lines). I need a similar message to pop up when on Firefox and not-set browsers (like a gaming console browser) but I also need a way to dissmiss it or ignore it because a big portion of my users are using those specific ones. Open to any ideas, thanks!

  • 2
    possible duplicate of [How to detect Safari, Chrome, IE, Firefox and Opera browser?](http://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser) – Burkhard Jul 22 '15 at 05:14
  • 6
    OMG. Have you even considered fixing your broken website instead?? This is an archetypical question related to the XY problem. http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem – connexo Jul 22 '15 at 05:21
  • (Reply to the Comment above) I Just needed a way to show a message to tell people that their browser isn't currently supported at the moment. Also that I am working on fixing it. – Isaiah Kahler Jul 22 '15 at 21:49

3 Answers3

0

In javascript detecting Firefox:

var isFirefox = typeof InstallTrigger !== 'undefined';   // Firefox 1.0+

Read more info and more browser detection: How to detect Safari, Chrome, IE, Firefox and Opera browser?.

As a simple example you can do:

var isFirefox = typeof InstallTrigger !== 'undefined';   // Firefox 1.0+
if (isFirefox) {
    alert("Please try other browser!");
}

Example: http://jsfiddle.net/ddan/3d81d3qv/

Community
  • 1
  • 1
DDan
  • 8,068
  • 5
  • 33
  • 52
0

You can retrieve the user agent from navigator.userAgent to determine what browser is being used and go from there.

Of course nothing stops the user from faking the user agent.

Puddler
  • 2,619
  • 2
  • 17
  • 26
0

Use

var x = navigator.userAgent;

It will give similar to this:

Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.134 Safari/537.36

You can block the browser based on this string

sinhayash
  • 2,693
  • 4
  • 19
  • 51