[Javascript] is their a javascript function, or DOM property to find the char limit of a table cell or div?

Paul Novitski paul at juniperwebcraft.com
Tue Jan 30 13:52:39 CST 2007


At 1/30/2007 08:24 AM, Lee Bettridge wrote:
>Content-class: urn:content-classes:message
>Content-Type: multipart/alternative;
>         boundary="----_=_NextPart_001_01C7448B.28869C13"
>
>  I need to manually scroll a large body of text in a table cell or 
> div tag and was wondering if their is a way to find out how many 
> characters will fit into an area of a given size ?
>
>Normally in a browser environment any overflow would automatically 
>be handled by scroll bars (unless scroll bars are explicitly turned 
>off), but I am working in a TV browser and remote control 
>environment and cannot use scroll bars.

At 1/30/2007 10:20 AM, John Warner wrote:
>Wouldn't the font the user has selected for his browser (if he chose 
>to override page - say vision problems) impact this?


I wonder if this is a table of content scrolling in the browser 
window or a table cell with content that scrolls because the cell has 
been styled with {overflow: scroll} in CSS?

Yes, so he would need to look up the current font size, line height, 
margins, and padding as determined by inline styling + stylesheets + 
default styling to calculate the height of text blocks in the 
scrolling area.  Unless of course the TV browser allows for a fixed 
font-size (ick) or isn't capable of font resizing (double-ick), in 
which case everything may be known from the outset.

If the content consists of a series of page elements (table rows, 
paragraphs, divs) then javascript can step through them until it 
finds one that begins below the bottom of the window and thereby 
determine through trial and error how many rows fit in the window 
without having to calculate anything.

It sounds like Lee is visualizing a page-up, page-down scenario in 
which the scrolling text moves up or down one div-height.  An 
alternative might be to move it up or down one or more rows (or a 
percentage of window height) and let the user key repeatedly to shift 
up & down.  In my experience some people are confused by page-up & 
page-down: because the entire contents of the window changes there's 
no perceptible movement up or down.

Regards,

Paul
__________________________

Juniper Webcraft Ltd.
http://juniperwebcraft.com 




More information about the Javascript mailing list