/    Sign up×
Community /Pin to ProfileBookmark

mozilla iframe resizing and rendering problem

hello everyone,
I have an iframe, which I need to resize automatically to fit its content. After a lot of searching, I found a javascript snippet that seemed to suit my needs (from [url]http://www.ozoneasylum.com/9671[/url]):

[CODE]
<script language = “javascript”>

function setCorrectIframeSize()
{
resizeIframe(‘myFrameID’);
}

function resizeIframe(id) {
frame = window.document.getElementById(id);
innerDoc = (frame.contentDocument) ? frame.contentDocument : frame.contentWindow.document;
objToResize = (frame.style) ? frame.style : frame;
objToResize.height = innerDoc.body.scrollHeight+’px’;
}

</script>
<input type = “button” value = “resize” onclick = “setCorrectIframeSize();”/>
<iframe width = “100%” name = “myFrameName” id = “myFrameID” src = “readme.html” ></iframe>
[/CODE]

The problem is that the script really works fine, in both IE and Mozilla, except in one case: When the iframe target file “readme.html” has many lines, (more than about 1500), mozilla fails to render correctly the iframe content after resizing (its last 100+ lines seem to repeat themselves). the readme.html contents don’t make any difference, I’ve tried it with many other files (or even plain characters in its source)…
Any ideas would be *very* appreciated…

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@shanterusanMar 27.2005 — hi! thank you so much for that link! I'm soooo grateful! Thank you!

Ahem. *turns back into mature adult*

I tried the code from the link, and it resized the iframe perfectly (in both IE and Firefox). I have a different problem though; for me it opens every link in a new window. That should have a simple fix, I hope, so once that's done I'll check out your problem too.
×

Success!

Help @peris spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...