473,407 Members | 2,312 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,407 software developers and data experts.

Is it possible to get document size?

Is it possible to get the actual document size? Not the window size, but
the actual rendered document size, which in my case is bigger than the
window.

I am trying to set up a form entry system where the user scrolls by the
UP and DOWN keys. The idea is to keep as much context on the screen.

Say the form has 15 lines, and 7 are displayed. The user starts on line
1, at the top of the screen. The text on the screen stays fixed, until
the user gets to the center of the page (line 4) and then scrolls one
line at a time to always keep the current line centered, until the user
gets to line 11, at which point the last 7 lines are displayed, and the
screen stops scrolling...

Does that make any sense? Basically, since the user probably wants to
refer to the lines that are both above and below the current line, I
want to keep the current line centered as much as possible....

So I am thinking of retrieving the size of the entire document, then the
size of the display window, and then calculating the percentage of the
document that is displayed, and scrolling a certain percentage with each
line....

Any suggestions?

--Yan
Apr 18 '06 #1
4 11708
Captain Dondo <ya*@NsOeSiPnAeMr.com> writes:
Is it possible to get the actual document size? Not the window size,
but the actual rendered document size, which in my case is bigger than
the window.


Not consistently, but most modern browsers accept:
document.documentElement.offsetWidth
and
document.documentElement.offsetHeight
(You should be in standards mode to guarantee that the documentElement
exists, otherwise you might get the result from document.body).

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Apr 18 '06 #2
Lasse Reichstein Nielsen wrote:
Captain Dondo <ya*@NsOeSiPnAeMr.com> writes:

Is it possible to get the actual document size? Not the window size,
but the actual rendered document size, which in my case is bigger than
the window.

Not consistently, but most modern browsers accept:
document.documentElement.offsetWidth
and
document.documentElement.offsetHeight
(You should be in standards mode to guarantee that the documentElement
exists, otherwise you might get the result from document.body).

/L

Hah! Googling on documentElement found this:

http://www.quirksmode.org/js/doctypes.html

For posterity....
Apr 18 '06 #3
Lasse Reichstein Nielsen wrote:
Captain Dondo <ya*@NsOeSiPnAeMr.com> writes:
Is it possible to get the actual document size? Not the window size,
but the actual rendered document size, which in my case is bigger than
the window.


Not consistently, but most modern browsers accept:
document.documentElement.offsetWidth
and
document.documentElement.offsetHeight
(You should be in standards mode to guarantee that the documentElement
exists, otherwise you might get the result from document.body).

/L


That does not do it. Try creating a very wide element that overflows the
window. In that case document.documentElement.offsetWidth returns the
window width.

I scrabbled around this for a while because I wanted to make a "dialog
box" (which was in fact an absolutely positioned div) "modal". So I
created a 0% opaque, full sized div to sit over the document, but under
the "dialog box" (I had to use opacity to allow the document to show
through because if I set the background-color to transparent, IE didn't
acknowledge that it was there, and allowed user interaction with the
underlying document!!)

So this blocker had to be full size.

I don't have the code to hand, it's at work. I'll post it on Monday.

ExG
Apr 22 '06 #4
Lasse Reichstein Nielsen wrote:
Captain Dondo <ya*@NsOeSiPnAeMr.com> writes:
Is it possible to get the actual document size? Not the window size,
but the actual rendered document size, which in my case is bigger than
the window.


Not consistently, but most modern browsers accept:
document.documentElement.offsetWidth
and
document.documentElement.offsetHeight
(You should be in standards mode to guarantee that the documentElement
exists, otherwise you might get the result from document.body).

/L


I found my code. It was the width it was having trouble with. If there
was a very wide element in the document, then
document.documentElement.offsetWidth did not work - just returned the
viewport width. I used

fcl.util.getDocumentWidth = function()
{
if (document.body.scrollWidth)
return document.body.scrollWidth;
var w = document.documentElement.offsetWidth;
if (window.scrollMaxX)
w += window.scrollMaxX;
return w;
};

fcl.util.getDocumentHeight = function()
{
if (document.body.scrollHeight)
return document.body.scrollHeight;
return document.documentElement.offsetHeight;
};
Apr 29 '06 #5

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

Similar topics

2
by: Jack | last post by:
Hi, I have the following javascript that is written in html. It works great. However, I need to transfer the concept to an asp application where the form itself is an asp page. I was wondering if...
1
by: Timo | last post by:
All my font-sizes are set as relative sizes in CSS (large, medium, small, x-small, etc). Let's say something is set in CSS to be xx-large, but a visually impaired user wants it displayed even...
4
by: frogman042 | last post by:
My daughter is playing around trying to learn JavaScript and she wrote a small program that prints out a message in increasing and decreasing font size and color changes. She is using document...
13
by: Paul | last post by:
Hi I have a .net application that shows the start page for a few seconds and then goes to another start page. I was wondering if it would be possible to put a count on the page to let the user...
4
by: dsimmons | last post by:
On my website http://seasidequilters.blogspot.com/ I'm having a problem that someone thinks might be associated with Firefox browsers. I'm hoping to find someone in this forum that might be...
5
by: WilliamRLinden | last post by:
Hi world! we are pretty new to JavaScript and have been struggling for now 2 days on this problem ... We would appreciate mercy if anyone can give us some. Basically we are trying to simulate...
2
by: wolfing1 | last post by:
Maybe this doesn't make any sense, but is it possible to dynamically resize an iframe to the height of its contained page? Something that works in Opera/Firefox/IE. I can resize it with a...
1
by: ara.t.howard | last post by:
hi all- i'm a totally js hack so go easy on me... i'd like to create a function that, given the size of a block of text in x = maximum number of chars y = total number of lines (this is in...
2
by: sbettadpur | last post by:
Hi everybody, Hi iam strugling with more than one submit buttons with in one form here is my code <form method="post" action="Offer.php" name='issueFrm' onSubmit="return fullOfferfields();">...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.