这很简单,我有一个链接列表,如果用户点击链接,div会加载一些内容(jwplayer占位符和歌曲标题),jwplayer应该启动。这是我的javascript(jquery和jquery-swfobject):
$(function() {
$('.song a').live('click', function() {
var title = $(this).find('span.title').text();
var file = $(this).attr('href');
$.ajax({
type: 'POST',
url: $('.songlocation').html(),
data: 'name=' + title + '&file=' + file,
success: function(html) {
$('.songplayer').attr('title', title);
$('.songplayer').html(html);
},
complete: function(request, status) {
$('#mediaspace').flash({
swf: $('.flashlocation').html(),
allowfullscreen: true,
allowscriptaccess: 'always',
wmode: 'opaque',
width: 238,
height: 24,
flashvars:
{
file: file,
autostart: true
}
});
if ($('#mediaspace').text().indexOf("Flash is disabled") == -1) {
$('.songplayer').show();
} else {
document.location = file;
}
}
});
return false;
});
});
$('。songlocation')包含/ Home / SongPlayer
/ Home / SongPlayer包含:
<div id="mediaspace">
Flash is disabled
</div>
<div id="name">
Song Title
</div>
<a href="http://url/to.mp3" class="download">Download MP3 >></a>
这在Opera / Firefox / Chrome / IE7 / IE8中完全正常,但在IE9中则不行 jwplayer加载得很好,但不是歌曲。所以在IE9中永远不会调用MP3文件