views:

30

answers:

1

I just asked a question here, about why an iframe_resize function wasn't working.

After troubleshooting, I found out that the problem is not the function, so I am posting a new question.

I have an index.html with this resize function:

function resize_iframe(new_height){
    document.getElementById('iframe001').style.height=parseInt(new_height) + 20 + 'px';
}

Then I have a form in index.html with target set to an iframe, and action set to query.php:

   <form action='query.php' target='iframe001'>

The in my query.php:

 //ALOT OF PHP HERE
 <body onload="parent.resize_iframe(document.body.scrollHeight)">
 <?php echo $results_table; ?>
 </body>

The problem is, in Chrome and Safari, the scrollHeight isn't changed at all.

In all other browsers, scrollHeight changes and the function works.

However, in Chrome/Safari, when clicking on a link anywhere on the page, and then clicking on the browser back button to return to the search results (iframe content), THEN the iframe is resized properly even in Chrome/Safari... ?

This is very strange behaviour for me.

Can somebody explain this?

Thanks

PS: I think this person has the same problem: http://stackoverflow.com/questions/3053072/iframe-resizing-with-scrollheight-in-chrome-safari

+1  A: 

Did you try offsetHeight property?

Divlancer
It WORKS!......
Camran