如何在 HTML5 檢測網頁瀏覽器支援


您可以嘗試執行以下程式碼,來檢測 Web 瀏覽器中可用的 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>

以下是結果

更新時間:29-Jan-2020

180 次瀏覽

開啟您的 職業旅程

透過完成課程來獲得證書

開始
廣告
© . All rights reserved.