manipulating Flash objects in IE8
Hello,
I'm trying to use jQuery to process embedded Youtube videos in a blog template. The idea is that someone posting a blog can simply paste in the auto-generated embed code, then when the page is viewed the script makes the neccessary tweaks. I've come up with the following code, which works in Firefox, Chrome and Safari:
- $(document).ready(function(){
-
- // fix embedded videos
-
- $("object").each(function(index){
-
- //set wmode
-
- $(this).children("param[name='wmode']").remove();
- $(this).prepend("<param name='wmode' value='transparent'></param>");
- $(this).children("embed").attr("wmode", "transparent");
-
- //set size
-
- var aspect = $(this).attr("width") / $(this).attr("height");
- $(this).attr("width", 595);
- $(this).attr("height", Math.floor(595.0 / aspect));
- $(this).children("embed").attr("width", 595);
- $(this).children("embed").attr("height", Math.floor(595.0 / aspect));
-
- //clone & replace
-
- $(this).replaceWith($(this).clone());
-
- });
- });
I've tried plenty of variations on this theme, but I still can't make it work in Internet Explorer 8. Any ideas?
Thanks