Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Resizing iframe height to fit page contents

Posted on 2004-05-01
6
Medium Priority
?
8,376 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

705 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