喵喵时光机
在全局对象上检测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>在创建的元素上检测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>检测某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>检测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>