Computer >> Máy Tính >  >> Lập trình >> Javascript

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

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

<!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>

Sau đây là kết quả:

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