By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,474 Members | 1,283 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,474 IT Pros & Developers. It's quick & easy.

A Width Changable Iframe

P: n/a
WH
While the whidth of the table can be set as 80%, the size of the iframe can
not be changed once set.

I am looking for a solution which the iframe's width can be set according to
the IE/Firefox/Opera's width. Is that possible?
Jul 23 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
WH wrote:
I am looking for a solution which the iframe's width can be set according to
the IE/Firefox/Opera's width. Is that possible?


Well, you can grab a reference to the frame element, and change its
style properties - this should work on recent versions (IE5+, Mozilla,
Opera7+).

---
<iframe id="foo" src="http://jibbering.com/faq/"></iframe>
<input type="button" onclick="bar('foo')" value="100%">

<script type="text/javascript">
function bar(frameId) {
var frame;
if(document.getElementById) {
frame=document.getElementById(frameId);
frame.style.width="100%";
frame.style.height="100%";
}
}
</script>
---

If this does not help, then please post a short test case demonstrating
your issue, and state the environment/browser you've executed the test in.
Jul 23 '05 #2

P: n/a
On Sat, 18 Sep 2004 06:54:43 GMT, WH wrote:
While the whidth of the table can be set as 80%, the size of the iframe can
not be changed once set.

I am looking for a solution which the iframe's width can be set according to
the IE/Firefox/Opera's width. Is that possible?


<style type='text/css'>
iframe {
width: 100%;
}
</style>

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.lensescapes.com/ Images that escape the mundane
Jul 23 '05 #3

P: n/a
'In line' with Andrew's suggestion, (ha, no pun intended re:styles), may I
recommend setting the body style too and set the margin & padding to 0px to
avoid application of default settings which may not allow the i-frame to
expand:
<body style="margin:0px; padding:0px;">
<iframe style="width:100%; height:100%; border:0; margin:0; padding:0;"
src="http://www.google.com">
</iframe>

-Jim

Jul 23 '05 #4

P: n/a
WH wrote:
While the whidth of the table can be set as 80%, the size of the iframe
can not be changed once set.
It can be changed, both explicitely and implicitely.
I am looking for a solution which the iframe's width can be set according
to the IE/Firefox/Opera's width. Is that possible?


Sure.

<iframe src="..." ... width="80%" height="...">
alternative
</iframe>

The "iframe" element above will always take 80% of the width of
the viewport or its parent element; only in working UAs, of course.
PointedEars
--
There never was a good war or a bad peace. -- B. Franklin
Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.