<!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 >);
          }
  }
</script>
</body>
</html>

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

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-02
  • 2022-02-22
  • 2021-10-16
  • 2021-11-23
  • 2021-08-19
  • 2021-10-30
猜你喜欢
  • 2022-01-08
  • 2022-12-23
  • 2021-07-31
  • 2021-11-04
  • 2022-12-23
  • 2022-12-23
  • 2021-09-16
相关资源
相似解决方案