Solved

Resizing iframe height to fit page contents

Posted on 2004-05-01
6
8,363 Views
Last Modified: 2012-06-21
hello,

is there a way (using javascript or another language), to get my <iframe height=""> to change dynamically as a new page is loaded in it?

I want the iframe height to change dynamically so that i don't have to use another set of scrollbars inside the iframe...

please check this website to see what i mean: http://69.194.150.152/calendar.asp

you can see that the calendar changes while the rest of the page remains the same size... for example, when you press the "view" button, the page changes, yet i want the iframe to be resized so that you don't get a large white space underneath.

----------------------HOW I THINK IT CAN BE DONE---------------------------
have a function on the calendar.asp that can change the height of the iframe (in javascript)

then for each page that is loaded in the iframe, it will contain an embedded variable that tells it the height, and calls the function calendar.asp to resize it...
------------------------------------------------------------------------------------

Can anyone provide me some code to do this?

thanks very much
0
Comment
Question by:selagea
6 Comments
 
LVL 3

Expert Comment

by:Sleepyhead_NO
ID: 10967437
i was unable to load your page, but i think this will work for you:

in calender.asp:
<iframe name="myiframe" src="iframe.asp"></iframe>
<script type="text/javascript">
function ChangeIframeHeight(NewHeight)
{
    document.frames.myiframe.style.height = NewHeight;
}
</script>

in iframe.asp:
<body onload="parent.ChangeIframeHeight('400px');">
0
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 500 total points
ID: 10967459
Just do the body tag to the calendar pages this way:

<body onload="resizeTo(document.body.scrollWidth,document.body.scrollHeight)">

When the calendar loads in it will resize the iframe

Cd&
0
 

Author Comment

by:selagea
ID: 10967666
thanks you very much, it works perfectly, and is easy to install
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 10967942
Glad we could help.  Thanks for the A. :^)

Cd&
0
 

Expert Comment

by:phylasv
ID: 12055723
OOps! wait a minute! There is a problem to this code: Why does the iframe shrink down after browsing many pages?
0
 
LVL 9

Expert Comment

by:Sar1973
ID: 37500066
What about iframed .html pages which contains autoexpanding/compressing menus?
Is there a way in the containing page to dynamically fit the height to the variable source page height?
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now