View Full Version : iframe Dilemma

05-11-2007, 08:21 PM
I am trying to have an iframe automatically resize to fit the content inside it. Here is what I have:


<iframe class="teacherpage" frameborder="0" src="http://www.albany.k12.or.us/wahs/teacherpages/harveysylvia/home.php"></iframe>


.teacherpage {
overflow-x: hidden;
width: 650px;

edit: I have searched for a solution, but all the ones I see call for code to be inserted into each page that is being displayed in the iframe. This is a major problem for me since I am designing these pages for the teachers at my school. There are sixty plus teachers all with many pages, and it would be very difficult to go back through each page and insert some code.

05-15-2007, 05:01 AM

05-15-2007, 05:40 AM
If the url is on another domain than the iframe then you won't be able to resize the iframe dymnamically any way due to security issues. If you are working on a page that is on the same domain as the src of the iframe then yes its possible. It will require javascript. The script found here doesn't require that you put anything into the pages that are to open in the iframe.

05-15-2007, 07:50 PM
I get a page not found error for that URL.

05-15-2007, 07:54 PM
Just click it, don't try copying and pasting it.

05-15-2007, 08:04 PM
Seems to work just fine. Thanks.

05-15-2007, 08:34 PM
Firefox is adding right and bottom scrollbars to the page, even though scrolling is set to no. It works in IE just fine though.

05-15-2007, 11:35 PM
Got link?

05-16-2007, 01:58 AM

I changed the overflow from visible to hidden and the width from 100% to 655px and that seems to fix the problem.

05-16-2007, 02:03 AM
Out of curiosity how did you get the job for webmaster for the school? Are you a student or something? Also I advise against the use of tables for page layout. Read: "Why Tables for Layout is Stupid? (http://www.hotdesign.com/seybold/)"

05-16-2007, 02:34 AM
I am a student at West Albany HS. Last year I took a class called computer applications and then advanced computer applications the next semester. The teacher of those classes is the webmaster of the schools website. I did well in the classes and he asked me if I would like to help him out. He is also the band director so he is very busy and has little time to update the site. I now maintain everything and recently I have been working on getting pages up for all the teachers.

And by the way, I do use divs for layout, but the majority of the site was done when I started. The district has a template for all the schools to use that we can't change. (Click on the "Select a school" drop down box). The only part of the site that I have complete control over is the teacher pages, which I designed from scratch. They are laid out with divs.