tags:

views:

146

answers:

2

How can I determine that sifr is finished running? I need to know the height of an element where there is sifr text on page load, but when I check the height, sifr has not yet completed and I get an incorrect value (the height of the element before sifr has been applied). And I definitely want to avoid having to place an arbitrary delay in finding the height. Any suggestions?

A: 

You could use the onReplacement callback, which is invoked each time an element is replaced. It's specified as an argument to sIFR.replace(), more here: http://wiki.novemberborn.net/sifr3/JavaScript+Methods.

From there on you'd use the FlashInteractor object, which is passed as the first argument, to get to the replaced element.

Do note though that when the page resizes, the text could wrap, changing the height of the Flash movie. There is no callback for this.

Mark Wubben
A: 

I spent a TON of time on this and finally came up with a cross-browser jQuery solution. I hope this helps a bunch of people in similiar situations:

<script src="/path_to_jquery/jquery.js" type="text/javascript" language="javascript1.2"></script>
<script language="javascript">
    function setEqualHeight(columns) 
    {
     var tallestcolumn = 0;
     columns.each(
     function() 
      {
        currentHeight = $(this).height();
        if(currentHeight > tallestcolumn) 
        {
        tallestcolumn = currentHeight;
        }
     }
     );
     columns.height(tallestcolumn);
    }

    $(window).load(function(){
     var dlay = setInterval(function(){
     if(jQuery('.sIFR-replaced').length>=sIFR.replacements.length){
      setEqualHeight($(".jqueryheight"));
      clearInterval(dlay);
     };
     },100);       
    });       
</script>