How to show warning "Refresh your Browser" when it does not support HTML5?

3

How to display the "Update Your Browser" warning when the user's browser does not support HTML5 tags or CSS3 properties?

An initiative that encourages this is the link site, but they do provide a script for it.

Would it be possible to do this without a javascript or jquery script, using only HTML5 and CSS3 techniques?

For example, if you use the <video> or <audio> tag by placing text inside it, before or after the <source> tags, as in the example below, this text will only be shown when the browser does not support these tags, consequently to html5. But I did not find a good way to style this warning. I also do not know if this warning would be the best way to do that.

<video id="aviso">
   Desculpe mas seu navegador não dá suporte a HTML5
</video>

Even though it is not possible, what is the best way to do this with javascript / jquery ?

    
asked by anonymous 13.01.2015 / 13:08

4 answers

0

There are only two ways I know of whether or not a browser supports the HTML5 and CSS3

The first is to check the User Agent of the browser, and doing the treatment according to the result, you can find out this via server that received the response request, and in the answer already do the handling of the page to be rendered, or via client , and rendering on the client itself.

PHP

$_SERVER['HTTP_USER_AGENT'];

JS

function UserAgente(){
      var ua = window.navigator.userAgent;
      return ua;
}

With this make a compatibility check according to the browser version used by the client ....

Here you can find a complete list of User Agents

This form of fact is the most arduous and laborious .....

The second way is to use Modernizr to detect if the browser supports this feature, this is the most appropriate way.

So there is no other secret, just import the library and test the features according to your need.

The complete documentation you find here.

Obs: One more detail, this goes of own opinion (in my case) it is no use trying to get the client to update the browser .... this only generates discomfort for those who already technology does not come with good eyes, what is worth more is try to produce something that works in all possible environments ... even if it looks ugly, what matters is the expected result to be obtained.     

13.01.2015 / 14:06
4

Hello, as our friend @Ricardo Peres said, just use link

Put it on your page.

<script src="modernizr.min.js"></script>

And do

if (Modernizr.canvas) {
  // Suporta HTML5
} else {
  // não suporta
}
    
13.01.2015 / 13:38
4

You can not detect "HTML5 support", but you can check support for individual features such as canvas, video, or geolocation.

There are 4 techniques to detect if browsers detect any functionality. These are:

1 - Checks whether a given property exists on a global object (such as window or navigator).

Example : testing geolocation support

2 - Create an element, then check if a given property exists on that element.

Example : testanto canvas support

3 - Create an element, check that a given method exists on that element, then call the method and check the value it returns.

Example : testing which video formats are supported

4 - Create an element, set a property for a given value, then verify that the property has maintained its value.

Example : testing which <input> types are supported

Source : Detecting HTML5 Features

    
13.01.2015 / 21:28
0

You could use browse happy to warn the user to update the browser

<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a
href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->

link

    
13.01.2015 / 16:01