Due to some circumstances, this blog is now up for sale, for more enquires contact: Plushista@gmail.com
RealcomBiz
Pin It

Detection Techniques to Check Browser Support For HTML5 Features

by Durodola Ridwan | Saturday, October 18, 2014 | 23 Comments

Any website is built with a common goal in mind: to make it work according to the latest specifications and web trends. Since the mobile Internet usage is growing with each passing day, it is becoming needful for site owners to develop a site that is optimized for mobile users. And HTML5 provides the potential to build mobile websites. This is why, HTML5 web development is becoming the most popular web trend used by webmasters around the world.



HTML5 introduced a lot of new and cool functionalities including some great semantic elements, audio and video support and the canvas tag. However, some old browsers don't provide support for HTML5, and thus you may think how to adopt HTML5 if your users don’t have HTML5-compatible browsers. But that's not what you should be thinking, as it is a misleading thought. Remember that the browsers that support HTML5 means that they support different features of it; and rather than detecting whether “browsers support HTML5”, you should detect if the new HTML5 functionality is supported in the browsers or not.

This post will help you explore how to detect browser support for the new HTML5 elements.


An Overview of the Detection Techniques

When a web page is rendered by a web browser, a Document Object Model (DOM) is created. A DOM is a collection of objects that specifies the HTML elements by a different object. Some of those elements include <p> tag, <span> tag and a few other tags. All of the DOM objects boasts a common set of properties, however certain objects may have more properties compared to others. Most importantly, browsers that support HTML5 features will contains some DOM objects having unique properties. And so, looking at the DOM will most likely help you know about the features that the browsers support.

Below is a list of four basic techniques that will help you detect whether a browser supports HTML5 feature or not.


1. Technique to identify whether a particular property exists on a “global object” such as window or navigator. For example, below is a function that helps to verify whether the browser supports geolocation or not.

function supports_geolocation() {
return !!navigator.geolocation;
}

2. Technique that allows users to create an element, and then test whether a certain property is governed by that element. This technique is quite useful to check for canvas support.

function supports_canvas() {
return !!document.createElement('canvas').getContext;
}

3. Third technique also help create an element, and verify if a certain method is characterized by that element or not. Next, call the method to find out the value it returns. For example, using this technique you can test video formats that are supported by a browser.

function supports_x123_baseline_video() {
if (!supports_video()) { return false; }
var m = document.createElement("video");
return m.canPlayType('video/mp3; codecs="avc1.42E01E, mp3a.40.2"');
}

4. You can use a detection technique that let you create an element, which is followed by setting a property for a certain value, and then testing whether the property has retained its value or not. For example, check out which <input> types are supported. 

var v = document.createElement("input_value");
v.setAttribute("type", "color");
return v.type !== "text";


A Look Into Modernizr – HTML5 Feature Detection Library

Modernizr JavaScript library is touted as the most viable solution for detecting support for HTML5 features. It uses the advanced JavaScript object detection techniques to check whether the current browser has implemented HTML5 and CSS3 features or not. This feature detection library makes it convenient for you to discover what can and cannot do with your current browser.

In order to use this library, you will have to incorporate the below mentioned <script> element in your page <head> section:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Detect Browser Support for HTML5 Features</title>
  <script src="modernizr.min.js"></script>
</head>
<body>
  ...
</body>
</html>

You do not need to run Modernizr manually and there's no modernizr_init() function that you'll need to call. Rather it runs automatically and creates a global object called as “Modernizr” that uses boolean properties for each feature that it tests. For example, in case your current browser supports the “canvas API” HTML5 feature, then the Modernizr.canvas property will return true. But, if the browser doesn't support canvas API, then the Modernizr.canvas property will return false.

if (Modernizr.canvas) {
  // draw some shapes!
} else {
  // native canvas support is not available
}

Note: Since the Modernizr detection library version keeps on updating, make sure to use the latest one to get optimal results.


Let's Wrap Up!

HTML5 is widely used for web development today, especially it is used by business entities that want to build a functional website that help them stay competitive in today's mobile marketplace. However, a lot of users still don't use browsers that support HTML5 functionality. And thus, while developing in HTML5 it becomes imperative to test whether the browser that your users are using supports the HTML5 features or not.



Amy Brown is a web developer by profession, a writer by hobby and works for WordPrax Ltd., a WordPress development services company. She loves sharing information regarding WordPress customization tips & tricks.



Go Social:

Subscribe For Free Updates!

*Please confirm the email sent to your inbox after clicking "Sign Up!".

23 comments : Post Yours! Read Comment Policy ▼
PLEASE NOTE:
We have Zero Tolerance to Spam. Chessy Comments and Comments with Links will be deleted immediately upon our review.

  1. This wonderful post is in fact so interesting and comic, I really loved this. Thanks intended for sharing this information.
    instagram shoutouts

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Get All the updates about t20 wc 2016. Livescore t20 wc 2016. Match details and match predictions icc t20 wc livescore

    ReplyDelete
  4. France Ligue 2 Live Stream
    Watch live football streaming online at livefootballontv1.com. Find out a complete tv guide of today's popular matches in Europe.

    ReplyDelete
  5. good It is certainly incredibly simple to download video lessons to your Product. this page that users happen to be demonstrating consequently Vidmate APK Android nice.

    ReplyDelete
  6. good USB line interconnection can be the simply one approach to copy data files this page Only believe about the difficulties that you get through SHAREit on Computer nice.

    ReplyDelete
  7. good introduce in Snapchat, 2015 revisions and because filters on snapchat The function is usually to become acquired as great.

    ReplyDelete
  8. Windows Live Hotmail or Hotmail is one of the most popular emailing service hotmail.com sign in

    ReplyDelete
  9. good Now you can easily watch your favorite movies this page After accessing the showbox apk record track down ShowBox Download Free nice.

    ReplyDelete
  10. This is very nice one and gives depth information. Thanks and keep posting! Thanks again for the blog article . Much thanks again. Great. hotmail sign in

    ReplyDelete
  11. Great Post! Learn some new tactics today. Thanks for sharing.

    ReplyDelete
  12. Well Said, you have furnished the right information that will be useful to anyone at all time. Thanks for sharing your Ideas.
    Node JS training in chennai | Node JS training institute in chennai

    ReplyDelete
  13. Let’s keep are safe place to play the very best free games for kids! Please click: wingsio | slither io | abc

    ReplyDelete
  14. You can receive or send emails to friends and colleagues as well as easy access to the application the Microsoft website. Let's create a separate account for her right now.
    hotmail login | create new hotmail account
    Creating a Gmail account is quick and easy. You can follow the tutorial to sign up Gmail here
    gmail login | google drive login


    ReplyDelete
  15. IOS 10 is the tenth major release of the iOS operating system developed by Apple Inc. to use it without any restriction imposed by Apple Inc.You can download iOS 10 Jailbreak. from CydiaNerd.

    ReplyDelete
  16. good Download Google Duo for Apple pc Computer here Google Duo for iOS but also sometimes it can come to be a aggravating nice.

    ReplyDelete

About Me

My Photo
Durodola Ridwan is a Professional blogger, SEO Consultant, Certified Web developer/designer and founder of www.realcombiz.com. He love writing about Blogging tips, SEO, and play around with codes. You can connect with him on facebook, twitter @realcombiz, and Google+.

Recent Posts

Let's Connect

Site Links

Copyright © 2014 RealcomBiz. All Rights Reserved.
Powered by Blogger