简体   繁体   中英

OnHover HTML5 audio on Safari

I created a simple nav bar with on-hover mp3/ogg audio playback. It works on all browsers except Safari on Windows, but judging by the autor it should work on it too. Can somebody take a look on Mac and let me know is it working http://goo.gl/h2K6PN

<audio id="aruba" controls preload="auto">
  <source src="audio/Aruba.mp3"></source>
  <source src="audio/Aruba.ogg"></source>
</audio>

<ul class="top-level">
<li><a href="#" class="palm-tree" id="arubaplay">Link</a></li>
</ul>

JS

window.onload=function(){

// collecting audio files
var aruba = document.getElementById('aruba');
var arubaplay=document.getElementById('arubaplay');

arubaplay.onmouseover=function(){
 aruba.play();
 return false;
};

Windows Safari does not support HTML Audio tags without Quicktime properly installed. Your link works on OS X Safari.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM