html5音频和跨浏览器问题 [英] html5 audio and cross browser issues
本文介绍了html5音频和跨浏览器问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在运行时使用jquery制作了一个音频(html5),它在Chrome上运行了
但不是IE10
这里是代码:
i made an audio(html5) with jquery on runtime and it worked
on chrome but not IE10
here's the code:
$(a).hover(function(){
var audio = $('<audio>', {
autoPlay : 'autoplay',
controls : 'controls'
});
var fileFormat = "mp3";
var canPlayMP3 = (typeof audio.canPlayType === "function" && audio.canPlayType("audio/mpeg") !== "");
if (!canPlayMP3) {
fileFormat = "ogg";
}
if(fileFormat == "mp3"){
addSource(audio, 'audio/ding.mp3');
}
else{
addSource(audio, 'audio/ding.ogg');
}
});
如何创建html5音频标签鼠标悬停动态
在每个浏览器上播放?
how to create an html5 audio tag on mouse hover dynamically
that plays on every browser?
推荐答案
(a).hover(function(){
< span class =code-keyword> var audio =
(a).hover(function(){ var audio =
(' < audio>',{
autoPlay:' autoplay',
控制:' controls'
});
var fileFormat = mp3;
var canPlayMP3 =( typeof audio.canPlayType === function&& audio.canPlayT ype( audio / mpeg)!== );
if (!canPlayMP3){
fileFormat = OGG跨度>;
}
如果(fileFormat == mp3){
addSource(audio,' audio / ding.mp3' 跨度>);
}
else {
addSource(audio,' 音频/ ding.ogg'跨度>);
}
});
('<audio>', { autoPlay : 'autoplay', controls : 'controls' }); var fileFormat = "mp3"; var canPlayMP3 = (typeof audio.canPlayType === "function" && audio.canPlayType("audio/mpeg") !== ""); if (!canPlayMP3) { fileFormat = "ogg"; } if(fileFormat == "mp3"){ addSource(audio, 'audio/ding.mp3'); } else{ addSource(audio, 'audio/ding.ogg'); } });
如何创建html5音频标签鼠标悬停动态
在每个浏览器上播放?
how to create an html5 audio tag on mouse hover dynamically
that plays on every browser?
将下面提到的代码放在页面标题中的标题标签下面然后检查。
< meta http-equiv =X-UA-Compatiblecontent =IE = 9; IE = 8; IE = 7/>
< meta http-equiv =X-UA-Compatiblecontent =IE = edge,chrome = 1/>
Put this below mentioned code below your title tag in header of your page then check.
<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
这篇关于html5音频和跨浏览器问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文