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;width: 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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM