views:

55

answers:

0

Hi

I am using jquery to slidetoggle some divs inside an iframe.

In IE, Firefox it is working perfectly. The divs are sliding open and closed and i am using the following code inside the slidetoggle callback to get the height of the iframe content and then shrink it back to where it should be

I am calling from within the slidetoggle callback;

This is my jquery slide which is at the child level

function toggleFast(obj) {
    var el = document.getElementById(obj);
    $j('#' + obj).slideToggle('fast', function () {
        parent.resizeIframeToFitContent();
    }); 
}

This is in my Parent Page

function resizeIframeToFitContent(){
 var obj = document.getElementById('bodyIframe');

 if (obj.contentDocument) {
    obj.height = obj.contentDocument.documentElement.scrollHeight + 30;
 } else {
    obj.height = obj.contentWindow.document.body.scrollHeight;
 }
}

so like is said this is working fine in IE and Firefox. Shrinking correctly and looking good.

but in chrome. when i get the scrollHeight using the function above it is returning the wrong value. it seems to be returning the value of the maximum scrollHeight the window was when the slideToggle Divs were open.

So instead of shrinking the iframe back to the correct size, it is returning the max height the frame went to and then adding the 30px on top.

So everytime a slideToggle is clicked the frame grows by the height of the open div + the 30px offset from the code above...

Anyone have any ideas...Or know what im talkin about

As an addition i wanted to see what the height of the documents were after each click on the toggle...

i used this code inside the iframe doucument

 $j(this).bind("resize", function () {
   alert($j(this).height());
 });

On Ie and firefox
the first height is 434...
click toggle
Height goes to 722
click same toggle again
Height jumps back to 434 which is correct

On Chrome the first height is 448 ... a bit of difference but thats ok)
click toggle
Height goes to 750
click same toggle again
Height now jumps up to 800
click toggle agaain
height goes to 850
click same toggle again
height is now at 900

Any Ideas Please

Thanks