I am loading the contents of an iframe based on the results of a SQL query which takes UI input. As such, the height of the iframe needs to be changed regularly in order for the page formatting to remain constant.
When the page loads initially, I use the following to determine the iframe's height:
onload="this.height=this.contentWindow.document.body.scrollHeight;"
This works when the page is loaded for the first time; but when the user dynamically changes the iframe's content, the onload is not retriggered, and the iframe retains its original height.
This is how the iframe is presented in my index.php when the page is initially loaded:
<script>document.write('<iframe id="mainpage-iframe" onload="this.height=this.contentWindow.document.body.scrollHeight;" src="page-body.php"></iframe>');</script>
When the user makes choices from a menu to update the iframe based on results from a SQL query, a function such as the following is triggered:
document.getElementById('mainpage-iframe').contentDocument.location.assign('page-body.php?selectvenue=' + venue + '&selectcity=' + city);
...which posts arguments to page-body.php.
So, my question is: is it possible to somehow 'append' to this result in order that the document.write function includes the onload action?