473,503 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Possible to resize an Iframe to its content's height?

Maybe this doesn't make any sense, but is it possible to dynamically
resize an iframe to the height of its contained page? Something that
works in Opera/Firefox/IE.
I can resize it with a
document.getElementById("frameItems").style.height = "200px" for
example, but was wondering if I could access somehow the full size its
inner page would take... which might not make much sense but still who
knows.

Mar 23 '06 #1
2 9975
wo******@gmail.com wrote:
Maybe this doesn't make any sense, but is it possible to dynamically
resize an iframe to the height of its contained page? Something that
works in Opera/Firefox/IE.
I can resize it with a
document.getElementById("frameItems").style.height = "200px" for
example, but was wondering if I could access somehow the full size its
inner page would take... which might not make much sense but still who
knows.

I haven't tried it, but can you use the size of the iframe's <body> element?

--
Ian Collins.
Mar 24 '06 #2

Ian Collins wrote:
wo******@gmail.com wrote:
Maybe this doesn't make any sense, but is it possible to dynamically
resize an iframe to the height of its contained page? Something that
works in Opera/Firefox/IE.
I can resize it with a
document.getElementById("frameItems").style.height = "200px" for
example, but was wondering if I could access somehow the full size its
inner page would take... which might not make much sense but still who
knows.

I haven't tried it, but can you use the size of the iframe's <body> element?

--
Ian Collins.

Made it work! What I did (copied from somewhere in the web):
In the "inner" page, an onload like this:
<body onload="parent.adjustIFrameSize(window);">

And in the actual page a js function like this:
function adjustIFrameSize(iframeWindow) {
if (iframeWindow.document.height) {
var iframeElement = document.getElementById ("frameItems");
iframeElement.style.height = iframeWindow.document.height + 'px';
iframeElement.style.width = iframeWindow.document.width + 'px';
} else if (document.all) {
var iframeElement = document.all["frameItems"];
if (iframeWindow.document.compatMode &&
iframeWindow.document.compatMode != 'BackCompat') {
iframeElement.style.height =
iframeWindow.document.documentElement.scrollHeight + 5 + 'px';
iframeElement.style.width =
iframeWindow.document.documentElement.scrollWidth + 5 + 'px';
} else {
iframeElement.style.height =
iframeWindow.document.body.scrollHeight + 5 + 'px';
iframeElement.style.width = iframeWindow.document.body.scrollWidth
+ 5 + 'px';
}
}
}

where frameItems is the name of the frame containing the page.
Tested in IE, Firefox and Opera and works in all of them so good enough
for me.

Mar 24 '06 #3

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

Similar topics

2
1404
by: Alex Blekhman | last post by:
Hello, I'm experienced Windows programmer, however, I'm quite novice in HTML technologies. Recently I was assigned a task to write small utility for internal use in our development team. I...
2
3264
riptide2049
by: riptide2049 | last post by:
I really have a problem here. I have a code that is suppost to take the href of a link from the right class;value of a link maked toreturn false. the value is a Media file the file is sent to...
0
7165
by: Tarik Monem | last post by:
I have been working on an all AJAX/DOM web site which is set to go live today and I thought I'd share my discoveries with all of you whom have helped me when I have encountered different issues along...
6
61355
by: deknoopjes | last post by:
I want to display a specific area of an external website using iFrames. A year ago I created such code successfully, but lost this code due to a crashed computer. Googling for any solutions did not...
3
2070
by: Jills | last post by:
Hi All, Does anyone have any idea about how can we resize an IFRAME dynamically according to its content from another domain? I want to increase the height according to the page that is...
1
1526
by: CJ4R | last post by:
Have an issue with an iframe in FF blocking links in a z-index layer behind the layer containing the iframe. It works in IE. I can't change the layer index of the iframe because it's content needs to...
0
7194
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7070
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
7316
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...
1
6976
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...
0
5566
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,...
1
4993
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...
0
4666
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...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.