JeZxLee Posted September 21, 2014 Share Posted September 21, 2014 Detect HTML5 & JavaScript Availability HTML4? Hi, I would like to detect if HTML5 and JavaScript are available using HTML4.Can someone help me with the above?My website requires both HTML5 and JavaScript so I would like to print an error message using HTML4... Thanks! JeZxLee Quote Link to comment Share on other sites More sharing options...
d13 Posted September 22, 2014 Share Posted September 22, 2014 Hello! HTML4 and 5 are actually a whole spectrum of technologies that blur into one another.That means you can't detect "HTML4" or "HTML5" as a single thing. What I usually do is detect for WebGL.There are a few ways to do that: http://stackoverflow.com/questions/11871077/proper-way-to-detect-webgl-support If a browser can do WebGL, it's a nice modern browser that contains most of important HTML5 things that we game developers like. Quote Link to comment Share on other sites More sharing options...
chg Posted September 22, 2014 Share Posted September 22, 2014 With regard to Javascript, I think the standard thing to do is to wrap your error message complaining it is disabled it in the noscript tag and make sure this is displayed clearly when it scripting is disabled. You can also use scripting to show HTML elements used by your game or even programmatically create your elements such as your canvas so that nothing but the error shows if scripting is not enabled.NB: The noscript tag ensures that search engine bots etc. don't mistake the javascript disabled message for the page's main content when indexing (you don't want someone that searches for your game to see the javascript message in their search engine) With regard to detecting whether HTML5 is supported, I think you could do this from your HTML 5 page (assuming Javascript is not disabled) by checking if the browser is in quirks mode which it will presumably use if it does not recognize the HTML5 doctype. Googling quirks mode detection suggests document.compatMode might be a property to check. As D13 suggests you also should test for (or handle failure to create) the HTML5 technologies you intend to use for your game. But probably don't test for WebGL unless you need it IMHO. Quote Link to comment Share on other sites More sharing options...
Sebi Posted September 22, 2014 Share Posted September 22, 2014 You could also use modernizr. That's what it's made for. http://modernizr.com/download/ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.