Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> JavaScript

วิธีตรวจสอบการรองรับเบราว์เซอร์ใน HTML5


คุณสามารถลองรันโค้ดต่อไปนี้เพื่อตรวจจับฟีเจอร์ Web Worker ในเบราว์เซอร์:

<!DOCTYPE HTML>
<html>
  <head>
    <title>Big for loop</title>
    <script src="/js/modernizr-1.5.min.js"></script>
    <script>
      function myFunction(){
        if (Modernizr.webworkers) {
          alert("Congratulations!! You have web workers support.");
        } else {
          alert("Sorry!! You do not have web workers support.");
        }
      }
    </script>
  </head>
  <body>
    <button onclick="myFunction()">Click me</button>
  </body>
</html>

ผลลัพธ์:

วิธีตรวจสอบการรองรับเบราว์เซอร์ใน HTML5