JS播放器——错误:我的返回错误不与IE10工作,但与所有其他浏览器工作
JS Player --- Err : My Return false doesnt work with IE10 but work with all other browser
我用javascript做了一个mp3播放器,它在除IE10以外的所有浏览器上都能完美运行
页面示例:http://www.mupiz.com/noon(尝试点击歌曲)
但是IE10遵循链接并忽略之前的脚本…
这是我的脚本:
var list = $("#playlist").find("a:not(.songLink)");
listNC=new Array();
for (var i=0;i<list.length;i++) { // we get all the song
list[i].rel = i;
$(list[i]).parent().parent().prepend("<td class='notplayed' width='25px'><img src='../../images/lecteur-B-playlist-play.png' style='z-index:10000'/></td>");
listNC[i]=girlify(list[i].href);
list[i].onclick = function(event) { // onclick on each link
if($(this).attr('class')!="songLink"){
soundManager.stopAll();
current = this.rel;
event.preventDefault();
lire_current(); // this play the song
return false; // **this does not work!**
}
};
这是CSS的专用部分
你有很多jQuery和常规DOM代码的混合匹配,这有点令人困惑。我认为它只能在其他浏览器中工作,只是运气不好。最终,我相信IE在你调用preventDefault
时出现错误,因为它有不同的事件模型,而你没有使用jQuery事件。这意味着preventDefault
没有完成它的工作,并且由于错误,return false
永远不会到达。
var listNC = [],
current;
$('#playlist')
.find('a:not(.songLink)')
.each(function (i) {
var $this = $(this);
$this
.attr('rel', i)
.parent()
.parent()
.prepend('<td class="notplayed" width="25px"><img src="../../images/lecteur-B-playlist-play.png" style="z-index:10000"/></td>');
listNC[i] = girlify($this.attr('href'));
})
.on('click', function (e) {
soundManager.stopAll();
current = $(this).attr('rel');
lire_current();
// Event control:
e.preventDefault(); //keeps link from being followed
//I don't think you want either of these next two lines:
e.stopPropagation(); //keeps event from bubbling...probably not what you want
return false; //causes same as calling e.preventDefault() e.stopPropagation()...probably not what you want
});
我当然不能测试它,但我认为它会做你想要的。
相关文章:
- dhtmlx多个调度器不工作错误”;调度程序未定义”;
- Javascript 确认框工作错误
- 变量中的类工作错误
- 为什么这个jQuery验证工作错误
- Cordova罗盘API(navigator.compass.watchHeading)不工作(错误代码3)
- Javascript不能在Chrome或IE9中工作-错误”;复选框未定义“;显示在FF JS控制台中
- JQuery UI对话框不能正常工作;错误信息“TypeError: undefined不是一个函数”
- Jquery/JS css动画在悬停时工作错误
- AngularJs Ng-Keypress事件工作错误
- Jquery 选择器不工作:错误:语法错误,无法识别的表达式:a[@href]
- 日期选择器范围工作错误
- 为什么我的Jquery Ajax请求不工作错误:未定义的索引:ProID
- 反应不工作.错误提示(index):13 Uncaught SyntaxError: Unexpected token
- 身份工具箱不工作-错误代码:IDP的错误响应
- jquery日期picker beforeShowDay工作错误的月份
- Javascript验证在c#中不工作(错误消息)
- 为什么?每个函数都工作错误
- 路由到api工作错误
- 子元素位置相对工作错误
- 从timeline2.6.1的例子不工作-错误链接是未定义的时间线代码0