A
Asterbing
I want to know the length in pixels of a document embedded in a iframe.
The way I go seems to work under IE but not under Firefox (about other
browsers I'll see later).
Here is my page for testing :
1) The page which will appear in the iframe is :
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>inside</title>
<script type="text/javascript">
function docsize(){
alert(this.document.body.scrollHeight + "px");}
</script>
</head>
<body bgcolor="white">
<form action="" method="post">
<input type="button" value="Size of Doc Inside" onclick="docsize();">
</form>
<p>ljlsqdjqlsd ljsqldjqs dlj lqsjkd lqsdkj lqskdjsq ldqsdlj lqsdkj
qslkdj ql qsldjqs dlqs jdlqs dlqsdj qsldj qsl dqlsd sqld jsqld qsdqsl
dlqs dqsl dlqs dlqs dlqsjd lqsd qsld qsdl qsdlqsj dlqsjd sqld qsld lsqd
lqzd qsld qsldjqs dlqs dlqs dlqs dlqs dlqsd qsl dqs dlqsd qsld qsld qsld
qsld qsld qsld qsl dsqld qsl dlqs dqsj dlqsd sqld qsld qsld qsljd qsldj
qsld qsld jqsld qsld jqsl dqsjld qsld jqsl dsql djqsld jqsld qsld qsld
qsl djqsld qsld qsldjqs ldj qsdl
<br><br>
That's all !</p>
</body>
</html>
2) The document with the iframe which will contains the first doc
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>iFrame resize</title>
<script type="text/javascript">
function resize(h)
{
var f = document.getElementById("container");
f.setAttribute("height", h);
}
</script>
</head>
<body style="background: purple">
<form action="" method="post">
<input type="button" value="500" onclick="resize(500);">
<input type="button" value="250" onclick="resize(250);">
</form>
<div style="position: absolute; visibility: visible; border: dotted
white">
<iframe id="container" width="731" height="100" src="some.htm"
scrolling="no" style="border: thin"></iframe></div>
</body>
</html>
So, to test, just do this :
1) clic to knwow current size
2) clic to resize the iframe
3) the size of doc inside shouldn't change with iframe size (I don't
want the iframe size, but the size of document inside)
It works under IE, not Firefox 1.5 under Windows
How to do it works ?
The way I go seems to work under IE but not under Firefox (about other
browsers I'll see later).
Here is my page for testing :
1) The page which will appear in the iframe is :
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>inside</title>
<script type="text/javascript">
function docsize(){
alert(this.document.body.scrollHeight + "px");}
</script>
</head>
<body bgcolor="white">
<form action="" method="post">
<input type="button" value="Size of Doc Inside" onclick="docsize();">
</form>
<p>ljlsqdjqlsd ljsqldjqs dlj lqsjkd lqsdkj lqskdjsq ldqsdlj lqsdkj
qslkdj ql qsldjqs dlqs jdlqs dlqsdj qsldj qsl dqlsd sqld jsqld qsdqsl
dlqs dqsl dlqs dlqs dlqsjd lqsd qsld qsdl qsdlqsj dlqsjd sqld qsld lsqd
lqzd qsld qsldjqs dlqs dlqs dlqs dlqs dlqsd qsl dqs dlqsd qsld qsld qsld
qsld qsld qsld qsl dsqld qsl dlqs dqsj dlqsd sqld qsld qsld qsljd qsldj
qsld qsld jqsld qsld jqsl dqsjld qsld jqsl dsql djqsld jqsld qsld qsld
qsl djqsld qsld qsldjqs ldj qsdl
<br><br>
That's all !</p>
</body>
</html>
2) The document with the iframe which will contains the first doc
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>iFrame resize</title>
<script type="text/javascript">
function resize(h)
{
var f = document.getElementById("container");
f.setAttribute("height", h);
}
</script>
</head>
<body style="background: purple">
<form action="" method="post">
<input type="button" value="500" onclick="resize(500);">
<input type="button" value="250" onclick="resize(250);">
</form>
<div style="position: absolute; visibility: visible; border: dotted
white">
<iframe id="container" width="731" height="100" src="some.htm"
scrolling="no" style="border: thin"></iframe></div>
</body>
</html>
So, to test, just do this :
1) clic to knwow current size
2) clic to resize the iframe
3) the size of doc inside shouldn't change with iframe size (I don't
want the iframe size, but the size of document inside)
It works under IE, not Firefox 1.5 under Windows
How to do it works ?