manipulating Flash objects in IE8

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:

  1. $(document).ready(function(){


  2.     // fix embedded videos


  3.     $("object").each(function(index){


  4.         //set wmode


  5.         $(this).children("param[name='wmode']").remove();
  6.         $(this).prepend("<param name='wmode' value='transparent'></param>");
  7.         $(this).children("embed").attr("wmode", "transparent");


  8.         //set size


  9.         var aspect = $(this).attr("width") / $(this).attr("height");
  10.         $(this).attr("width", 595);
  11.         $(this).attr("height", Math.floor(595.0 / aspect)); 
  12.         $(this).children("embed").attr("width", 595);
  13.         $(this).children("embed").attr("height", Math.floor(595.0 / aspect));


  14.         //clone & replace


  15.         $(this).replaceWith($(this).clone());


  16.     });

  17. }); 

I've tried plenty of variations on this theme, but I still can't make it work in Internet Explorer 8. Any ideas?

Thanks