# Resizing Iframe via PHP



## enoctis (Aug 28, 2005)

I have created an iframe in an HTML file that pulls up a PHP file & have a javascript code that will automatically resize the Iframe according to it's content. The problem is that the code I have requires the use of an onload event handler utilized in a body tag, & the PHP file contains some header information, which is causing errors.

The warning states that the PHP file can't utilize it's header information because it has already been called (I imagine from the onload event handler). Is there any way around this?

The code in the HTML file looks like so:





Then the code (in HTML format) that I am attempting to use in the PHP looks like so (yes, I have to convert it... that's not the problem):
<script>
function resizeToContent(){
var x =0;
var y =this.document.body.scrollHeight;
while (x < y){
x+=1;
}
parent.document.getElementById("dynamIframe").style.height=x+20
}
</script>
<body onload="resizeToContent()">

Again, I can get the code to work in PHP, but when loaded it pops up with several warnings about the header information. If you need to see what the actual warning says I can get that information to you, but am limited on time at the current moment.

Thanks for any help!


----------



## DJ-Zep (Mar 11, 2006)

Have you tried removing the onload function just to see if it is the problem?


----------



## enoctis (Aug 28, 2005)

*yep*

without the onload event i don't get any errors. sorry for the delayed response. i posted that before i went to the field; im in the military.


----------



## DJ-Zep (Mar 11, 2006)

Try changing onload to onmouseover.


----------

