Changing object embed source via jquery
I need to be able to load up dif开发者_开发技巧ferent flash files when users click an image in my gallary. My current solution works perfectly fine in Firefox, but Chrome and IE are not working and it isn't giving any error messages.
I use jquery to change the embed source
$('#flash embed').attr('src', msg.d);
<object id="flash">
<embed src="" type="application/x-shockwave-flash" width="800" height="600"></embed>
</object>
I have used the same solution as you to do the same and mine works perfectly in all browsers, do you think it might be your click event? Try to alert some messages to see where it actually gets to in the code.
Note my code below:
$("object embed").attr("src", id);
Try this for embeding:
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="800" height="600" id="flash">
<embed src="" type="application/x-shockwave-flash" width="800" height="600" />
</object>
and this for switching the swf file:
$(document).ready(function() {
$('#galleryImageID').click(function() {
$("#flash>embed").attr('src', msg.d);
});
});
You could also use swfobject.
I found a few solutions. I ended up using the second one.
Method 1: I insert the entire object tab with embed dynamically. That seems to fix flash loading issues in Chrome and IE.
Method 2: I found a jquery flashloader plugin that is simple to use and works well. http://jquery.lukelutman.com/plugins/flash/
Method 3 Use jquery swfObject http://jquery.thewikies.com/swfobject/examples
精彩评论