Solved

Resizing iframe height to fit page contents

Posted on 2004-05-01
6
8,364 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
RSS Feeds--IE 13 166
Migrating to Exchange 2013 4 41
Advice on what platform to use for a web app for AWS 3 93
how to extract window origin in spring 2 63
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…
There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

919 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

16 Experts available now in Live!

Get 1:1 Help Now