1. 怎么检测浏览器是否支持html5

利用HTML5新标签对象的方法来进行检测,比如Canvas对象的getContext()、Video对象的canPlayType等。如果浏览器支持HTML5,则返回相应的期望值(返回函数体,布尔值为true),否则无法获得期望值(返回undefined,布尔值为false)。

Canvas对象的getContext

//方法一

/**

*[supportHtml5言成科技&HTML5学堂]

*@return{[type]}[description]

*/

functionsupportCanvas(){

return(typeofdocument.createElement('canvas').getContext==="function");

}


console.log(supportCanvas());

Video对象的canPlayType

//方法二

/*

*[supportsVideo言成科技&HTML5学堂]

*@return{[type]}[description]

*/

functionsupportVideo(){

return!!document.createElement('video').canPlayType;

}


console.log(supportVideo());


2. 如何判断浏览器是否支持HTML5 Canvas

需要准备的材料分别有:电脑、浏览器、html编辑器。

1、首先,打开html编辑器,新建html文件,版例权如:index.html。

3. 怎么判断浏览器是否支持html5的某些属性例如:required,placeholder.还有其它

常规的做法就是先判断浏览器的类型与版本号,然后可以判断是否支持HTML5.

比较省事的做法就是执行HTML5中的特有函数,有try可以测试是否正确执行。由于各浏览器版本对html5的支持度不同,这种情况只适用使用大多数的html5方法或属性。

4. jquery 判断浏览器是否支持HTML5

判断浏览器是否支持HTML方法较多,下面的供参考;得到结果后就可以给出自己的提示信息了,可以创作发挥。例子中就只是一个简单的alert提示
<script type="text/javascript">
window.onload = function() {
if (window.applicationCache) {
alert("浏览器支持HTML5");
} else {
alert("浏览器不支持HTML5");
}
}
</script>

5. html5中怎么判断浏览器类型

用JS来判断:

<script>
(){
varuserAgent=navigator.userAgent;//取得浏览器的userAgent字符串
varisChrome=userAgent.indexOf("Chrome")>-1;//判断是否Chrome浏览器
varisOpera=userAgent.indexOf("Opera")>-1;//判断是否Opera浏览器
varisIE=userAgent.indexOf("compatible")>-1&&userAgent.indexOf("MSIE")>-1&&!isOpera;//判断是否IE浏览器
varisFF=userAgent.indexOf("Firefox")>-1;//判断是否Firefox浏览器
varisSafari=userAgent.indexOf("Safari")>-1;//判断是否Safari浏览器

if(isIE){
varIE5=IE55=IE6=IE7=IE8=false;

varreIE=newRegExp("MSIE(\d+\.\d+);");
reIE.test(userAgent);

varfIEVersion=parseFloat(RegExp["$1"]);
IE55=fIEVersion==5.5;
IE6=fIEVersion==6.0;
IE7=fIEVersion==7.0;
IE8=fIEVersion==8.0;

if(IE55){return"IE55";}
elseif(IE6){return"IE6";}
elseif(IE7){return"IE7";}
elseif(IE8){return"IE8";}
}
elseif(isFF){return"FF";}
elseif(isChrome){return"Chrome";}
elseif(isOpera){return"Opera";}
elseif(isSafari){return"Safari";}
}

console.log(myBrowser());//会输出你使用的浏览器类型
</script>

6. 怎么知道浏览器是否支持html5

可以通过检查是否浏览器支持某个特定的html5功能,比如检查是否支持canvas:

varsupportCanvas=(typeofdocument.createElement('canvas').getContext==="function");
if(supportCanvas){
//...
}else{
alert("检测回到您正在使用旧版浏答览器,推荐您升级到新版以获取最佳体验!");
}

第二种方法:

functionsupports_video(){
return!!document.createElement('video').canPlayType;
}

if(supports_video()){
//...
}else{
alert("检测到您正在使用旧版浏览器,推荐您升级到新版以获取最佳体验!");
}

7. 怎么判断浏览器是否支持html5的indexedDB

indexedDB=indexedDB||webkitIndexedDB||mozIndexedDB||null;
if(indexedDB){
alert('支持');
}else{
alert('不支持');
}

PC端支持度:

FireFox 10+(完全支持)、Chrome 23+(完全支持)、Opera15+(15+用的就是专Chrome内核了所以都一样了,完属全支持)IE10+(部分支持)

结论:如不考虑IE,目前可放心使用

8. js如何判断浏览器是否支持html5

方法一:

if(typeof(Worker)!=="undefined"){
alert("支持html5");
}else{

alert("不支持html5");
}

方法二:

if(window.applicationCache){
alert("支持html5");
}else{

alert("不支持html5");
}

9. 检测浏览器是否支持html5

  1. 在全局对象上检测


    <!doctypehtml>
    <htmllang="zh_CN">
    <head>
    <metacharset="UTF-8">
    <metaauthor="suifengtec">
    <title>applicationCacheTest</title>
    <script>
    window.onload=function(){
    if(window.applicationCache){
    document.write("Yes,.");
    }else{
    document.write("No,.");
    }
    }
    </script>
    </head>
    <body>
    </body>
    </html>
  2. 在创建的元素上检测

    <!doctypehtml>
    <htmllang="zh_CN">
    <head>
    <metacharset="UTF-8">
    <metaauthor="suifengtec">
    <title>SimpleSquare</title>
    <scripttype="text/javascript">
    window.onload=drawSquare;

    functiondrawSquare(){
    varcanvas=document.getElementById('Simple.Square');
    if(canvas.getContext){
    varcontext=canvas.getContext('2d');

    context.fillStyle="rgb(13,118,208)";
    context.fillRect(2,2,98,98);
    }else{
    alert(".");
    }
    }
    </script>
    </head>
    <body>
    <canvasid="Simple.Square"width="100"height="100"></canvas>
    </body>
    </html>
  3. 检测某HTML5方法是否返回期望的值

    <!doctypehtml>
    <htmllang="zh_CN">
    <head>
    <metacharset="UTF-8">
    <metaauthor="suifengtec">
    <title>VideoTest</title>
    <script>
    functionvideoCheck(){
    return!!document.createElement("video").canPlayType;
    }

    functionh264Check(){
    if(!videoCheck){
    document.write("not");
    return;
    }

    varvideo=document.createElement("video");
    if(!video.canPlayType('video/mp4;codecs="avc1.42E01E,mp4a.40.2"')){
    document.write("not");
    }
    return;
    }

    document.write("Yourbrowserdoes");
    h264Check();
    document.write("supportH.264video.");
    </script>
    </head>
    <body>

    </body>
    </html>
  4. 检测HTML5元素是否能保留值

    <!doctypehtml>
    <htmllang="zh_CN">
    <head>
    <metacharset="UTF-8">
    <metaauthor="suifengtec">
    <title>RangeInputTest</title>
    <script>
    functionrangeCheck(){
    vari=document.createElement("input");
    i.setAttribute("type","range");
    if(i.type=="text"){
    document.write("not");
    }
    return;
    }

    document.write("Yourbrowserdoes");
    rangeCheck();
    document.write("supportthe<code><inputtype=range></code>inputtype.");
    </script>
    </head>
    <body>

    </body>
    </html>

10. 如何判断浏览器不支持html5

JavaScript一种直译式脚本语言,是一种动态类型、弱类型、基于原型的语言,内置支持类型。
HTML5万维网的核心语言、标准通用标记语言下的一个应用超文本标记语言(HTML)的第五次重大修改。2014年10月29日,万维网联盟宣布,经过接近8年的艰苦努力,该标准规范终于制定完成
接下来我教大家如何用javascript判断浏览器是否支持HTML5
一:
打开编辑器,或者JetBrains WebStorm
我一般用notepad++,其实都一样,只要能写代码,记事本也OK
然后选择你需要修改的html文件
二:
在文件中,加入如下js代码
<script>
window.onload = function() {
if (window.applicationCache) {
alert("你的浏览器支持HTML5");
} else {
alert("你的浏览器不支持HTML5");
}
}
</script>
三:
然后打开你需要测试的浏览器,我用的chrome,当然,你也可以测试手机浏览器
打开这个文件后会弹出提示。
四:
当然,也有可能你的浏览器不支持HTML5,则会弹出,说明你是时候更换浏览器了!
五:
到这里,你就可以判断你的浏览器是否支持html5啦,欢迎你加入HTML5,相信你会有更好的体验