如何在 HTML5 中檢查 Web 瀏覽器支援


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

以下為結果

更新於: 29-Jan-2020

181 次瀏覽

開啟你的 職業生涯

透過完成課程獲得認證

開始學習
廣告