Reputation: 1
I have an iframe that re-sizes its own content. The First time the iframe loades, the content re-sizes fine, but content not changing on subsequent resizing or page scrolling.
I have tried onresize,onmove...
<script type="text/javascript">
function autoIframe(frameId) {
try {
frame = document.getElementById(frameId);
innerDoc = (frame.contentDocument) ? frame.contentDocument : frame.contentWindow.document;
if (innerDoc == null) {
// Google Chrome
frame.height = document.all[frameId].clientHeight + document.all[frameId].offsetHeight + document.all[frameId].offsetTop;
}
else {
objToResize = (frame.style) ? frame.style : frame;
objToResize.height = (innerDoc.body.scrollHeight +200) + 'px';
//document.getElementById("autosizeframe").style.height=(innerDoc.body.scrollHeight+18)+'px';
//alert(frame.style.height+'-'+innerDoc.body.scrollHeight)
}
}
catch (err) {
document.getElementById("autosizeframe").style.height = '1600px';
document.getElementById("autosizeframe").style.width = '1000px';
//alert('Err: ' + err.message);
window.status = err.message;
}
}
Upvotes: 0
Views: 3166
Reputation: 15978
I have made an iframe auto resizer script too, years ago. Maybe it is helpful for you: http://www.professorweb.de/javascript-ajax/iframe-hohe-an-dessen-inhalt-automatisch-anpassen-v2.html
Upvotes: 1