zoukankan      html  css  js  c++  java
  • chrome不支持embed标签解决方案

    <!DOCTYPE html>
    <html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
    </head>
    <body>
    <div>
        <button style="height: 20px; 50px;"  onclick="playAudio()">播放</button>
    </div>
    <script>
        //setInterval(playAudio, 5000);
    
        function playAudio() {
               if (!!window.ActiveXObject || "ActiveXObject" in window){
                console.log("The browser is IE!");
             $('embed').remove();   
             $('body').append('<embed src="../../audio/prompt-tone.mp3" autostart="true"  height="0" width="0" hidden="true"  loop="false">');
             /* $('body').append('<embed src="../../audio/video.mp4" autostart="true"  hidden="false"  loop="false">'); */
              }else{
                  console.log("The browser is not IE!");
                  $('#embed').remove();   
                  $('body').append('<iframe id="embed" src="../../audio/prompt-tone.mp3" autostart="true"  height="0" width="0" hidden="false"  loop="false"></iframe>');
              }
      }
    </script>
    </body>
    </html>

    实际使用过程中发现chrome不支持embed标签,火狐和IE均支持,这里在谷歌和火狐下使用iframe代替了embed,在IE下仍使用iframe

  • 相关阅读:
    HackerRank
    HackerRank
    LeetCode "Kth Smallest Element in a BST"
    HackerRank
    HackerRank
    LeetCode "Roman to Integer"
    LeetCode "Integer to Roman"
    LeetCode "Majority Element II"
    HackerRank
    HackerRank
  • 原文地址:https://www.cnblogs.com/thiaoqueen/p/8074530.html
Copyright © 2011-2022 走看看