亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

檢測瀏覽器是否支持html5?

檢測瀏覽器是否支持html5?

慕少森 2018-08-14 10:07:20
檢測瀏覽器是否支持html5
查看完整描述

1 回答

?
喵喵時光機

TA貢獻1846條經驗 獲得超7個贊

  1. 在全局對象上檢測


    12345678910111213141516171819<!doctype html><html lang="zh_CN"><head>    <meta charset="UTF-8">    <meta author="suifengtec">    <title>applicationCache Test</title>    <script>        window.onload = function() {            if (window.applicationCache) {                document.write("Yes, your browser can use offline web applications.");            } else {                document.write("No, your browser cannot use offline web applications.");            }        }    </script></head><body></body></html>
  2. 在創建的元素上檢測

    1234567891011121314151617181920212223242526<!doctype html><html lang="zh_CN"><head>    <meta charset="UTF-8">    <meta author="suifengtec">    <title>Simple Square</title>    <script type="text/javascript">        window.onload = drawSquare;          function drawSquare () {            var canvas = document.getElementById('Simple.Square');            if (canvas.getContext) {                var context = canvas.getContext('2d');                  context.fillStyle = "rgb(13, 118, 208)";                context.fillRect(2, 2, 98, 98);            } else {                alert("Canvas API requires an HTML5 compliant browser.");            }        }    </script></head><body>    <canvas id="Simple.Square" width="100" height="100"></canvas></body></html>
  3. 檢測某HTML5方法是否返回期望的值

    123456789101112131415161718192021222324252627282930313233<!doctype html><html lang="zh_CN"><head>    <meta charset="UTF-8">    <meta author="suifengtec">    <title>Video Test</title>    <script>        function videoCheck() {            return !!document.createElement("video").canPlayType;        }          function h264Check() {            if (!videoCheck) {            document.write("not");            return;            }              var video = document.createElement("video");            if (!video.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"')) {                document.write("not");            }            return;        }          document.write("Your browser does ");        h264Check();        document.write(" support H.264 video.");    </script></head><body>  </body></html>
  4. 檢測HTML5元素是否能保留值

    12345678910111213141516171819202122232425<!doctype html><html lang="zh_CN"><head>    <meta charset="UTF-8">    <meta author="suifengtec">    <title>Range Input Test</title>    <script>        function rangeCheck() {            var i = document.createElement("input");            i.setAttribute("type", "range");            if (i.type == "text") {                document.write("not");            }            return;        }          document.write("Your browser does ");        rangeCheck();        document.write(" support the <code><input type=range></code> input type.");    </script></head><body>  </body></html>


查看完整回答
反對 回復 2018-09-18
  • 1 回答
  • 0 關注
  • 685 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號