Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
157
rated 0 times [  164] [ 7]  / answers: 1 / hits: 20761  / 14 Years ago, wed, june 16, 2010, 12:00:00

I'm trying to resize (make bigger or smaller) an iframe based on it's contents. After a click on each page a method is called which does the resizing.



In Chrome I can make the iframe bigger, but not smaller. document.body.scrollHeight is always the biggest value.



So if one big page sets #iframe.height = '620px', and someone clicks on a link to page with less content scrollHeight will remain at 620px instead of decreasing.



What's the proper way of handling this in Chrome/Safari?


More From » html

 Answers
2

Before you ask for the height of the document inside the iframe you should set the height of the iframe object to auto. Something like this:



objIframe = document.getElementById('theIframeId');    
objIframe.style.height = 'auto';


And now:



document.body.scrollHeight


returns the actual height of the document.


[#96476] Monday, June 14, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
janettejordynm

Total Points: 550
Total Questions: 94
Total Answers: 98

Location: Senegal
Member since Fri, Aug 21, 2020
4 Years ago
;