has.js
has.js tests are very simple to perform and use has('feature')
like syntax and return a Boolean value. The code in the previous example could be written as:
<script> var videoElement = ""; $(document).ready(function(){ if(has("video")){ // video is supported by the browser and can play it. $("#result").html("Video is supported"); videoElement = document.createElement('video'); $("body").append(videoElement); }else{ // load via flash or something else $("#result").html("Video is not supported, use Flash or something else."); } }); </script>
In this case, has("video")
will return a Boolean value to help developer make a decision. Sometimes features are partially supported. To understand this, let's take the same example of displaying video content. We can check if a video tag is supported or not, but this is not sufficient as we might need to play a certain format like Ogg, Mp4, MKV, and so on. We need to...