473,699 Members | 2,501 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:e xpression(docum ent.contentIFra me.window.conte ntTable.clientH eight)"

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.w indow.document. recalc(true);

contentIFrame.f rames.frameElem ent.style.heigh t =
contentIFrame.w indow.contentTa ble.clientHeigh t;

}
Any ideas

cheers

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

h = document.body.s crollHeight;
w = document.body.s crollWidth;
this.style.heig ht = h + 20;
this.style.widt h = 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.goo gle.com>...
Is JavaScript an option? Try:

h = document.body.s crollHeight;
w = document.body.s crollWidth;
this.style.heig ht = h + 20;
this.style.widt h = 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.f rames.frameElem ent.style.heigh t =
contentIFrame.d ocument.body.sc rollHeight;

}

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
2383
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 : function resize(){ displayFrm = document.getElementById("ifrmDisplay"); innerDoc = (displayFrame.contentDocument) ?displayFrm.contentDocument : displayFrm.contentWindow.document;
3
1443
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 navigation links and one chart object (currently an ActiveX control but we will be switching to native .NET controls soon). The number of frames shown on the page will be selected by the user dynamically at run time. What I need to do is define a...
1
1773
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 the size window's body scrollHeight so that way i dont need any scrolls for my iframe but the let page containing the iframe do the scrolling for the iframe so how can i make that happen, is one of the iframe events does detect any changes to...
5
9760
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
4485
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 includes background music with a javascript music player on the main page below an iframe that is used for all content and navigation of the site and so that the music doesn't reload each time a page is switched. There is another javascript to resize...
1
10383
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 doesn't cause a problem and the resize works correctly. On Firefox, if an image extends below the last line of text in the document, that bit gets chopped off. In other words, the returned document height doesn't allow for the image. My code for...
13
4408
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 appreciated. Here's the resize.js var sResizableElement = "TH"; //Elements to be resized var iResizeThreshold = 8; var iEdgeThreshold = 8; var iSizeThreshold = 20; var sVBarID = "VBar"; var oResizeTarget = null; //position and distance moved
1
2688
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 another iframe (ie. suppFrame) which loads content from this left menu. The reason for the second iframe is some of the pages have different left menus. this works fine, apart from resizing of the page. I do not wish to use scroll bars. Say if I...
0
8613
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9172
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9032
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8880
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7745
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6532
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
2344
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.