Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > How do we get the iframe window size?

Reply
Thread Tools

How do we get the iframe window size?

 
 
paul
Guest
Posts: n/a
 
      01-06-2006
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




 
Reply With Quote
 
 
 
 
Bart Van der Donck
Guest
Posts: n/a
 
      01-08-2006
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

 
Reply With Quote
 
 
 
 
Paul
Guest
Posts: n/a
 
      01-09-2006
HI! thanks bart,

Paul



*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Get parent iframe element in iframe Cleaner1912@gmail.com Javascript 0 09-27-2006 05:16 AM
Need to get offsetLeft of an iframe or div inside another iframe Nathan Carr Javascript 0 09-17-2004 01:27 PM
IFRAME - Refresh Table on Parent Window - maintain IFRAME State Scott ASP General 6 04-14-2004 05:48 AM
Get form values from iframe (1) to iframe (2) inside a layer in iframe (1) Daedalous Javascript 3 01-16-2004 11:08 AM



Advertisments