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

How to get length of document in an iframe

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 ?
Jun 14 '07 #1
3 4023
In article <MP************************@news.tiscali.fr>, no@thanks.com
says...
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>
OK, I've changed the scrollHeight with offsetHeight and it works for
Firefox 1.5 (not tested in 2.0 : if someone can tel me)

So, now, I would like it works for Netscape and Mozilla. So, I've tried
with "this.document.documentElement.scrollHeight", but I fall down in
same problem as the was I had with Firefox.

So, what's the good expression for Netscape and its derivated browsers ?

After I will wish to know for the browsers used under Linux : Konqueror
and others you'll tell me (I don't use Linux)...
Jun 14 '07 #2
Asterbing wrote:
>
OK, I've changed the scrollHeight with offsetHeight and it works for
Firefox 1.5 (not tested in 2.0 : if someone can tel me)
Purely personally, my first port of call would have been to not use an
<iframeat all. It isn't really needed anyway and I have to say I
simply could not see why you had gone that route at all.
Jun 15 '07 #3
Asterbing wrote:
OK, I've changed the scrollHeight with offsetHeight and it works
for Firefox 1.5 (not tested in 2.0 : if someone can tel me)
"The Magpie" <us****@pigsinspace.co.ukwrote:
: Purely personally, my first port of call would have been to not use
: an <iframeat all. It isn't really needed anyway and I have to say
: I simply could not see why you had gone that route at all.

Two questions:
(1) How would you do it?
(2) If you did go the iframe route, how would you do it?

--
Jim Carlock
Custom Swimming Pool Designers
http://www.aquaticcreationsnc.com/sw...c/viewing1.php
Jun 27 '07 #4

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

Similar topics

4
by: PHP2 | last post by:
how I can create frame inside in total middle of document with? I have one htnl and I need html page totaly in middle..
26
by: Dave Hammond | last post by:
In document "A.html" I have defined a function and within the document body have included an IFRAME element who's source is document "B.html". In document "B.html" I am trying to call the function...
2
by: Robert Oschler | last post by:
I have an IFrame whose document is created completely by Javascript code at runtime. The document in the IFrame accesses Javascript functions in the top level document. This works fine most of...
8
by: '69 Camaro | last post by:
Perhaps I'm Googling for the wrong terms. Does anyone have links to examples of the syntax necessary to read the HTML on another Web page when that HTML is produced from JavaScript using the...
8
by: Henrik Stidsen | last post by:
I am trying to access a table in an iframe via javascript. It sounds easy - but it won´t work... The iframe is added to the document via someContainerElement.innerHTML = "<iframe...>", it has...
8
by: hyejin | last post by:
I have a problem with dynamic iframe and document.close() on Firefox. Below two files create a dynamic iframe by JavaScript. These two samples do not have any problems on IE. But, on Firefox, the...
23
by: vunet | last post by:
It is recommended by some sources I found to create IFrames in IE using document.createElement('<iframe src="#">') instead of document.createElement('iframe'). Why and what browser versions to...
8
by: removeps-groups | last post by:
Is there any way to control the space between top of browser or frame and document body? What I have is this: There is a simple file test1.html, and file test.html that displays test1.html in an...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.