views:

1479

answers:

1

Hi Folks, I've managed to rewrite a script wich makes Images resize to 100% width of their parent Div Container To a Script that now lets Swf embed objects resize (Original Image resize Script by Oliver Boermans ollicle.c o m/eg/jquery/imagefit/ )

All i did is replaced the img with an "embed" in all lines where the parameters of the img tag should replace the width and height values.

In Firefox everything is working but in IE 7 no Luck at all.

Here a link to my Project

watch the flash video resizing nicely in firefox, while IE 7 is shouting out an error.

Here is my jquery js function:

(function($) {
$.fn.imagefit = function(options) {
 var fit = {
  all : function(imgs){
   imgs.each(function(){
    fit.one(this);
    })
   },
  one : function(img){
   $(img)
    .width('100%').each(function()
    {
     $(this).height(Math.round(
      $(this).attr('startheight')*($(this).width()/$(this).attr('startwidth')))
     );
    })
   }
 };

 this.each(function(){
   var container = this;

   // store list of contained images (excluding those in tables)
   var imgs = $('img', container).not($("table img"));

   // store initial dimensions on each image 
   imgs.each(function(){
    $(this).attr('startwidth', $(this).width())
     .attr('startheight', $(this).height())
     .css('max-width', $(this).attr('startwidth')+"px");

    fit.one(this);
   });
   // Re-adjust when window width is changed
   $(window).bind('resize', function(){
    fit.all(imgs);
   });
  });
 return this;
};

})(jQuery);

The each functions are responsible for going thru all divs i called from the trigger function:jQuery(document).ready(function(){ jQuery('.widget-content').flashfit(); });

How can i make it work for Internet Explorer and Chrome as well ?? any ideas ?

+1  A: 

Have you thought about using swffit instead? This works rather well for resizing Flash both within a container as well as full-browser sized Flash files.

http://swffit.millermedeiros.com/

Something else to consider is the actual structure of the Flash file, it should be set up to update the position of the elements based upon the stage size or things can get pretty ugly.

Hope that helps.

Liam