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

How do we get the iframe window size?

P: n/a
HI! I have an script that resizes an iframe and it works fine but now I need
to know how to get the iframe size after it has been resized for another
task,

Below is the iframe resizing script that is placed in the head of the
document.

<script language="JavaScript">
<!--
var origheight = 0;
function autoResize(id){
var newheight;
if (!window.opera && !document.mimeType && document.all &&
document.getElementById)
newheight=document.getElementById(id).contentWindo w.document.body.offsetHeight;
else if(document.getElementById)
newheight=document.getElementById(id).contentWindo w.document.body.scrollHeight;
document.getElementById(id).height= (newheight + 0) + "px";
if
(document.getElementById(id).contentWindow.locatio n.href.indexOf("index_test.html")>0
&& origheight>0)
document.body.style.height = origheight;
}
//-->
</script>
I then use this has my iframe tag on order to get the iframe to resize.

<iframe src="main_iframe.html" id="Iframemain" name="Iframemain"
height="400" width="450" scrolling="no" frameborder="0" marginwidth="0"
marginheight="0" onLoad="autoResize('Iframemain');">Some text here</iframe>
This script works fine and there is another small piece that is loaded in
another jscript which is as follows "origheight =
document.body.clientHeight;"

Can someone help me this ?

Thanks in advance :)

Paul


Jan 6 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
paul writes:
HI! I have an script that resizes an iframe and it works fine but now I need
to know how to get the iframe size after it has been resized for another
task,

Below is the iframe resizing script that is placed in the head of the
document.

<script language="JavaScript">
<!--
var origheight = 0;
function autoResize(id){
var newheight;
if (!window.opera && !document.mimeType && document.all &&
document.getElementById)
newheight=document.getElementById(id).contentWindo w.document.body.offsetHeight;
else if(document.getElementById)
newheight=document.getElementById(id).contentWindo w.document.body.scrollHeight;
document.getElementById(id).height= (newheight + 0) + "px";
if
(document.getElementById(id).contentWindow.locatio n.href.indexOf("index_test.html")>0
&& origheight>0)
document.body.style.height = origheight;
}
//-->
</script>
I then use this has my iframe tag on order to get the iframe to resize.

<iframe src="main_iframe.html" id="Iframemain" name="Iframemain"
height="400" width="450" scrolling="no" frameborder="0" marginwidth="0"
marginheight="0" onLoad="autoResize('Iframemain');">Some text here</iframe>


The following should give you the current height/width of the iframe
with id "Iframemain":

<script language="javascript">
function sn()
{
alert('height is now '+document.getElementById("Iframemain").height)
alert('height is now '+document.getElementById("Iframemain").width)
}
</script>
<input type="button" onClick="sn()" value="Show height/width">

--
Bart

Jan 9 '06 #2

P: n/a
HI! thanks bart, :)

Paul

*** Sent via Developersdex http://www.developersdex.com ***
Jan 9 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.