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

posted @ 2017-12-20 16:38  Rainyn  阅读(8254)  评论(0编辑  收藏  举报