0

OK, I want to do browser detection; I know that everyone say not to. But here's why. I have a WebGL app/page. Detecting WebGL is easy. But if WebGL is not supported, I want to give the user information on what to do next. To do that, I need the browser, the platform and the version. So I get why everyone says to use feature detection, but in this case if I want to give instructions I have to know the browser.

For example, with Firefox I'll tell a user to change an about:config setting whereas with Safari it's on a developer menu (if memory serves).

If there is a better approach, I'm all ears. If not, is there a decent browser detection library that is consistently maintained and deals with all the edge cases or inconsistencies in the way browsers are reported.

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52

1 Answers1

1

Check out this site: http://www.khronos.org/webgl/wiki/FAQ

On get.webgl you have subpage called troubleshooting.
That page detect your browser, OS and other.
You don't have to write it on your own when it's already done.

Detecting:

if(!window.WebGLRenderingContext) {
    // the browser doesn't even know what WebGL is
    alert("webgl not supported, visit http://get.webgl.org");
}
else {
    var canvas = document.getElementById("canvasID");
    var context = canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
    if(!context) {
        // browser supports WebGL but initialization failed
        alert("webgl is supported but here is another problem, visit http://get.webgl.org/troubleshooting");
    }
}

It's everything what you have to do.

trebor
  • 724
  • 5
  • 16
  • Thanks. But I know how to check for WebGL. The point of the question is I'm looking for browser detection so I can move to a page that explains what that browser's options are for WebGL. For example, this is often given as an answer: http://www.quirksmode.org/js/detect.html But this doesn't detect an iPad at all, and misidentifies Chrome on an iPad. I'm looking for a library that stays up to date so I don't have to adjust it all the time. As it is I'm using the above link, and just finding various machines and noting where it doesn't work and fixing. I'd like a better solution. – Paul Jacobs Sep 24 '13 at 22:56