I have a WebGL browser game that does not work for users that have the "Use hardware acceleration when available" setting unchecked in Chrome, they get a message that says "You need a browser which supports WebGL to run this content, please try using Firefox". I would like to catch this error, and display a custom message/send them to my guide page which shows them how to enable hardware acceleration in Chrome, so they don't get turned off and leave all together. How would I be able to do this?
Asked
Active
Viewed 779 times
0

gman
- 100,619
- 31
- 269
- 393

daniel metlitski
- 747
- 3
- 11
- 23
-
there is no error to catch – Jaromanda X Apr 20 '17 at 00:20
-
@JaromandaX well, I would like to catch the popup so I can display my own custom version – daniel metlitski Apr 20 '17 at 00:31
-
May be relevant. http://stackoverflow.com/questions/11871077/proper-way-to-detect-webgl-support – Apr 20 '17 at 00:43
1 Answers
0
The following piece of code would work for you:
var hasWebGL = (function() {
if (!window.WebGLRenderingContext) {
return 0;
}
var canvas = document.createElement('canvas');
var gl = canvas.getContext("webgl");
if (!gl) {
gl = canvas.getContext("experimental-webgl");
if (!gl) return 0;
}
return 1;
})();
if (!hasWebGL) alert('Custom message!');
But you might want to check the full script I found over there that checks webgl compatibility.
Hope it help you.

Mauro Aguilar
- 1,093
- 13
- 22