473,388 Members | 1,277 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

HELP: Dynamically resizing iFrame

I really need some help - i have already pulled out 1/2 my hear and
the rest is following quickly.....

I am designing a page containing an iFrame, the contents of which are
selected dynamically by the user, and it needs to resize
correspondingly - both height and width. the width isn't a problem; it
is set from its parent object using width=100%, but the height is a
killer.

Basically the user selects a menu item and the src of the iFrame is
set to that choice, but each selection has a different height - and
the width of the iframe also changes depending on the width of the
menu to its left.

i have tried to set a dynamic expression in its style property:

style="height:expression(document.contentIFrame.wi ndow.contentTable.clientHeight)"

but this works erratically

i have tried writing a seperate function which resizes the iframe when
a new choice is made, but have found that the function sets the iframe
to the height of the PREVIOUS object displayed. i cannot seem to be
able to access the current object no matter how i do it?

function setSize() {

//contentIFrame.window.document.recalc(true);

contentIFrame.frames.frameElement.style.height =
contentIFrame.window.contentTable.clientHeight;

}
Any ideas

cheers

tim
Jul 20 '05 #1
2 10116
Is JavaScript an option? Try:

h = document.body.scrollHeight;
w = document.body.scrollWidth;
this.style.height = h + 20;
this.style.width = w + 20;

This might be slightly off, but I've done something similar to that in the past.
Jul 20 '05 #2
sp*******@marx7.org (Trent) wrote in message news:<22*************************@posting.google.c om>...
Is JavaScript an option? Try:

h = document.body.scrollHeight;
w = document.body.scrollWidth;
this.style.height = h + 20;
this.style.width = w + 20;

This might be slightly off, but I've done something similar to that in the past.


Mate your a ledgend!!
thought id send a reply to let you know how i solved the problem - the
scrollHeight didnt work directly (although it did access the correct
height), as the iFrame was still somehow caching the values of the
previous content element, or not updating them quickly enough.

BUT by calling a function to set the size of the iFrame after the
contents have been updated:

function setSize() {

contentIFrame.frames.frameElement.style.height =
contentIFrame.document.body.scrollHeight;

}

and then calling the function again in the onload event of the iFrame
the cached values (or how ever the problem is caused) are updated in
time for the second call.

Thanks
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: khothikhe | last post by:
Can someone help me here because this is really killing me! the problem is, i have this javascript code in my aspx page that i want it to work on almost all browsers, especially opera and safari...
3
by: Bill Zack | last post by:
I have an interesting little ASP.NET problem. I have to position and show multiple "frames" in an IE6 browser at run time in a singe ASP.NET page. Each "frame" will contain a couple of...
1
by: Paul Fi | last post by:
I have this problem with iframes: i want to resize iframe's height when the window inside the frame is resized or when the src attribute of iframe changes so make the height of iframe equal to...
5
by: Angel | last post by:
Is there a way to create an IFRAME dynamically via VB.NET. In other words creating the HTML element in the server side code? thanks in advance....
3
by: PCgeek | last post by:
sorry moved this over to javascript forum, didn't mean to post 2x! Hi guys, I'm trying to put the finishing touches on my website and could really use some help on this particular issue. My page...
1
by: Dave | last post by:
Usual apologies if this is old territory. I'm resizing a bunch of iframes on a page to the height of their contained documents. Some of the contained documents contain IMG tags. On IE this...
13
by: bgraphics2031 | last post by:
I'm trying to get this iframe to dynamically resize by dragging a vertical bar, but it's not working in Mozilla (It originally worked in IE but I've been trying to port it over). Any help will be...
1
helpmepls
by: helpmepls | last post by:
i have a site where I have an iframe mainFrame which loads page content from the main menu (top horizontal menu). within this mainFrame is a second menu to left specific to the loaded page, and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.