473,385 Members | 1,863 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,385 software developers and data experts.

Resizing an IFrame

hi

I'm trying to change the size of an iframe. In the following page, how
should I do it?

<html>

<head>
<script language="javascript">
function resize_frm() {
I1.width=400;
}
</script>
</head>

<body>
<p onclick="resize_frm()">RESIZE</p>

<iframe name="I1" src="contents.htm" width="200" height="150">
Your browser does not support inline frames or is currently configured not
to display inline frames.</iframe>

</body>

</html>
Jul 20 '05 #1
2 22718
"H.A.P" <ha***@hotmail.com> wrote in message
news:bk************@ID-51430.news.uni-berlin.de...
hi

I'm trying to change the size of an iframe. In the following page, how
should I do it?

<html>

<head>
<script language="javascript">
function resize_frm() {
I1.width=400;
}
</script>
</head>

<body>
<p onclick="resize_frm()">RESIZE</p>

<iframe name="I1" src="contents.htm" width="200" height="150">
Your browser does not support inline frames or is currently configured not
to display inline frames.</iframe>

</body>

</html>


If you have an inline frame with id:

<iframe id="I1" src="contents.htm" width="200" height="150">

than you could write:

document.getElementById("I1").width = 400

Jul 20 '05 #2
"H.A.P" <ha***@hotmail.com> writes:
I'm trying to change the size of an iframe. In the following page, how
should I do it? <script language="javascript" The type attribute is required, and language is deprecated:
<script type="text/javascript">
function resize_frm() {
I1.width=400;
You shouldn't access named elements as properties of the global object.
Few browsers allow that (although one of them is used quite a lot).

Either
var iframe = document.getElementsByTagName("iframe")[0];
or give the iframe an id and use document.getElementById.

To change the width, use style.width:
iframe.style.width = "400px";
Remember the unit, it is required in CSS.
<iframe name="I1" src="contents.htm" width="200" height="150">


Don't use the width and height attributes, but use CSS instead:
<iframe name="I1" id="iframe1Id" src="contents.htm"
style="width:200px;height:150px;">

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #3

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

Similar topics

4
by: khothikhe | last post by:
can some one help me here coz 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 : ...
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...
5
by: Paul Fi | 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...
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...
1
by: sam | last post by:
Hi all, Hope some expert can help me resolve this. I am using the following code to resize an iframe according to the content in it so that the iframe does not use its scroll bar and uses the...
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...
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.