Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

length of a web page in pixels 1

Status
Not open for further replies.

dorling

Technical User
Mar 25, 2004
80
GB
is there a way of finding out how long a web page is in pixels???

i need this to be in a script on a page

thanks in advance

Jonathan D
 
you could take a screen shot, then open it up in photoshop and measure it... or do you need to measure it in the script?

[conehead]
 

i need this to be in a script on a page

No, there is no way to do this. The [tt]<body>[/tt] tag does not have a [tt]height[/tt] attribute.

*cLFlaVA
----------------------------
Breaking the habit...
 
i need to do this in script as the page lenght can and will change??

thanks in advance

Jonathan D
 

I'm a freaking liar.

In your body tag, put this:

[tt]<body ... id="body">[/tt]

Then, wherever you need to determine the height, put this:

[tt]var the_height = document.getElementById('body').offsetHeight;[/tt]

*cLFlaVA
----------------------------
Breaking the habit...
 
so basic i put this "<body ... id="body">" in the page i need to find out the height of and the following in the iframe

var the_height = document.getElementById('body').offsetHeight;

thanks in advance

Jonathan D
 
Should be fine. I have limited experience with iFrames.

*cLFlaVA
----------------------------
Breaking the habit...
 
how can i get the output as text in html page. i put in the code i am using? any help please

Code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd">[/URL]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body id="body">

var the_height = document.getElementById('body').offsetHeight; 


</body>
</html>

thanks in advance

Jonathan D
 
Code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd">[/URL]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body id="body">

<script language="javascript">
<!--
var the_height = document.getElementById('body').offsetHeight;
document.writeln("The body height is " + the_height.toString() + " pixels.");
-->
</script>


</body>
</html>

*cLFlaVA
----------------------------
Breaking the habit...
 
I think we need to go back a few pages.


The script you were given is Javascript. You cannot just put it within the HTML and have it work.
You need to place the script between <script> tags

What the script is doing is setting a variable names "the_height" to the value of the body elements height.

to use the value you need to refer to the variable within some more javascript.

I have a feeling that you may be trying to reinvent the wheel.
what actually is it you are trying to do? WHat is your end goal?
There may well be a better way.

"I'm making time
 
Why do you keep changing your question?

*cLFlaVA
----------------------------
Breaking the habit...
 
because i need to do all of these think!

and as i do them i see what other think i need to do

thanks in advance

Jonathan D
 
So now you want to, in page1.html, find out the height of page2.html, even though page2.html is not opened, so you can print the height of page2.html in page1.html?

What in the world is it you're trying to accomplish?

*cLFlaVA
----------------------------
Breaking the habit...
 
basic yes please

thanks in advance

Jonathan D
 
What in the world is it you're trying to accomplish?

That's a good question ????

[conehead]
 
You certainly cannot find out the height of the [tt]<body>[/tt] tag of a page that is not opened.

You'd have to open the page, find the height, store it in a variable, then print it on the main page after (I guess) closing the popup window.

*cLFlaVA
----------------------------
Breaking the habit...
 
so that a iframe can be the full length of the page they are insert with the full length

thanks in advance

Jonathan D
 
so how can i do that

i know i am asking ask but i need this for a school project?

thanks in advance

Jonathan D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top