Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> JavaScript

Cách kiểm tra hỗ trợ trình duyệt web trong HTML5

Bạn có thể chạy mã sau để phát hiện tính năng web worker trong trình duyệt:

<!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("Chúc mừng!! Bạn có hỗ trợ web workers.");
        } else {
          alert("Rất tiếc!! Bạn KHÔNG có hỗ trợ web workers.");
        }
      }
    </script>
  </head>
  <body>
    <button onclick="myFunction()">Click me</button>
  </body>
</html>

Kết quả:

Cách kiểm tra hỗ trợ trình duyệt web trong HTML5