Checking Browser Versions

3

I'm making a website and would like to put a browser check that the user is using.

I do not want the site to be used in IE 6, 7, and 8. In addition to some older versions of Firefox you have in those Linux environments.

If the user's browser are some of these old ones I want to redirect the user to a page where he can download a more recent browser.

But I'm wondering if these old browsers understand jQuery, why I was thinking of doing a routine through that library.

Or is there any other way to do this? I do not know.

    
asked by anonymous 23.07.2015 / 18:30

1 answer

4

Use the link

Add this to the header:

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

And at the bottom of the page this:

<script>
// Detecta se o navegador é antigo
if(Modernizr.mq('only all') === false) {
   // Navegadores modernos suportam "Media Query", se o navegador não tiver suporte então direciona com location
   window.location.href = "http://exemplo/upgrade";
}
</script>
</body>
</html>

The address http://exemplo/upgrade is where you will link to the new browsers.

    
23.07.2015 / 18:36