473,505 Members | 14,686 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Making an iframe just big enough, but no bigger

Hi,

Does anyone know a cross-browser way of making an iframe just as big
as the HTML content of its source, but no bigger, either width or
height wise. Using 100% attributes for iframe width and height seem
to make the iframe as big as its parent container. I would also
prefer a solution where there is no scrolling.

Thanks for any help, - Dave

Mar 14 '07 #1
3 11039
Scripsit la***********@zipmail.com:
Does anyone know a cross-browser way of making an iframe just as big
as the HTML content of its source, but no bigger, either width or
height wise.
There is none. That would be against the principles of iframe rendering: the
iframed document is presented autonomously, and the document that embeds it
just offers a display area for it. Using client-side scripting, you might be
able to detect the size requirements of the iframed document, though I doubt
that, and it would surely not be cross-browser.
Using 100% attributes for iframe width and height seem
to make the iframe as big as its parent container.
More or less so.
I would also
prefer a solution where there is no scrolling.
This sounds like you would like to smoothly include a file in another.
That's not really a job for iframe, and it's discussed in the FAQ.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Mar 14 '07 #2
On Wed, 14 Mar 2007 13:30:19 -0700, la***********@zipmail.com wrote:
Hi,

Does anyone know a cross-browser way of making an iframe just as big
as the HTML content of its source, but no bigger, either width or
height wise. Using 100% attributes for iframe width and height seem
to make the iframe as big as its parent container. I would also
prefer a solution where there is no scrolling.

Thanks for any help, - Dave
There are some scripts on http://www.DynamicDrive.com that will do this as
long as both pages are in the same domain/host.

Search their site for IFRAME
Mar 14 '07 #3

George L. Sexton wrote:
On Wed, 14 Mar 2007 13:30:19 -0700, la***********@zipmail.com wrote:
Hi,

Does anyone know a cross-browser way of making an iframe just as big
as the HTML content of its source, but no bigger, either width or
height wise. Using 100% attributes for iframe width and height seem
to make the iframe as big as its parent container. I would also
prefer a solution where there is no scrolling.

Thanks for any help, - Dave

There are some scripts on http://www.DynamicDrive.com that will do this as
long as both pages are in the same domain/host.

If both pages are from same domain then all you need to do is check
scrollHeight/scrollWidth -

IFrame.width=IFrame.document.body.scrollWidth
IFrame.height=IFrame.document.body.scrollHeight

E.G.-UNTESTED-

<html>
<head><title>Sometr</title>
<script type="text/javascript">

function OpenFrame(){
var Iframe=document.frames[0]
Iframe.src="somePage.html"
Iframe.onload=
function(){
Iframe.width=Iframe.document.body.scrollWidth
Iframe.height=Iframe.document.body.scrollHeight
}
}

</script>
<body style="text-align:center">
<button onclick="OpenFrame()">Text</button><br>
<IFRAME src="about:blank" width="50%" height="30%">your browser
doesn;t support frames(bad browser :-< )</iframe>
</body>
</html>

Mar 15 '07 #4

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

Similar topics

2
2956
by: David Bradbury | last post by:
I currently have an iframe on a webpage into which users can insert content. They can further customise the text as I've included buttons such as Bold, Italic, Bullet point etc. This is done along...
7
4828
by: Christopher J. Hahn | last post by:
I'm trying to use a script-generated form to submit to a script-generated iframe. The problem I'm running into is that the iframe is not assuming the name I assign it. IE6 on Win2000. FF1.0.2+...
0
1202
by: laredotornado | last post by:
Hi, I am trying to get my iframe to occupy the entire height of the table cell in which it is located. Sadly, this table cell may have variable height and the height=100% attribute doesn't seem...
1
7549
by: Rich | last post by:
Is there any reason why I should not be able to use an .aspx page with an IFRAME? I want to do something like this: <IFRAME ID="AFrame" SRC="PMSTAuth.aspx" ... </IFRAME>. I took a quick run at it...
2
6904
by: Dee | last post by:
Hi I have to <asp:button>'s one on top of the other in a cell of a Table layout. When I put a <br> I get too big a gap. Without it they are touching. The only way I can think of separating them...
2
1333
by: Laphan | last post by:
Hi All I'm using ASP to squirt some text into JS so that the JS write it into an iFrame, but JS keeps giving me unterminated string errors when the text is more than 1 line's worth. I thought...
7
3015
by: e_matthes | last post by:
Hello everyone, I've read enough about email validation to know that the only real validation is having a user respond to a confirmation message you've sent them. However, I want to store the...
1
4128
by: gary.comstock | last post by:
We have a non asp web page that contains a hyperlink which opens an iframe. The iframe is hidden until the hyperlink is selected then javascript toggles the visibility to 'visible'. Inside the...
1
1664
by: satishbjoshi | last post by:
Hi, can you please help me with the subjected issue. i am trying to make the background transparent of an iframe which is compatible with html 4.0. i am using the follwing code <iframe...
0
7216
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
7098
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
7303
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,...
0
7471
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...
0
5613
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
5028
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
3187
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
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
407
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...

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.