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

Spill overflow text to another DIV

Say I have a text area. When the user clicks a button the entered text
displays in a DIV. If there's too much text to fit in that DIV then the
overflow text (the text that doesn't fit in the first DIV) displays in
an adjacent DIV.

Is there a way to know if there's "overflowing" text and, if there is,
if there a way to know what that text is?

Andrew Poulos
Aug 8 '05 #1
6 9141
Andrew Poulos wrote:
Say I have a text area. When the user clicks a button the entered text
displays in a DIV. If there's too much text to fit in that DIV then the
overflow text (the text that doesn't fit in the first DIV) displays in
an adjacent DIV.

Is there a way to know if there's "overflowing" text and, if there is,
if there a way to know what that text is?

Andrew Poulos


You could look at the innerHTML of the second div or look for text
nodes with values other than empty strings.

But there is likely some other way related to however you are doing
the overflow.

--
Rob
Aug 8 '05 #2
RobG wrote:
Andrew Poulos wrote:
Say I have a text area. When the user clicks a button the entered text
displays in a DIV. If there's too much text to fit in that DIV then the
overflow text (the text that doesn't fit in the first DIV) displays in
an adjacent DIV.

Is there a way to know if there's "overflowing" text and, if there is,
if there a way to know what that text is?

Andrew Poulos

You could look at the innerHTML of the second div or look for text nodes
with values other than empty strings.

But there is likely some other way related to however you are doing the
overflow.


Sorry, I think I've not explained it correctly. Text will only go into
the second DIV if it doesn't fit in the first. So my question is
reworded to, given a DIV of a known size and how can I know how much
text will fit in it before it overflows?

I'm happy enough to count lines and words per line but I don't know
where the overflow occurs.

Andrew Poulos
Aug 8 '05 #3
"Andrew Poulos" <ap*****@hotmail.com> wrote in message
news:42***********************@per-qv1-newsreader-01.iinet.net.au...
RobG wrote:
Andrew Poulos wrote:
Say I have a text area. When the user clicks a button the entered text
displays in a DIV. If there's too much text to fit in that DIV then the
overflow text (the text that doesn't fit in the first DIV) displays in
an adjacent DIV.

Is there a way to know if there's "overflowing" text and, if there is,
if there a way to know what that text is?

Andrew Poulos

You could look at the innerHTML of the second div or look for text nodes
with values other than empty strings.

But there is likely some other way related to however you are doing the
overflow.


Sorry, I think I've not explained it correctly. Text will only go into
the second DIV if it doesn't fit in the first. So my question is
reworded to, given a DIV of a known size and how can I know how much
text will fit in it before it overflows?

I'm happy enough to count lines and words per line but I don't know
where the overflow occurs.


You can't, unless you hardcode the font size, *and* use a mono-spaced font
(i.e. Courier). And then only if you examine the exact pixel height and
width for that particular size up front.

Can't you solve this another way instead? Autoscroll? Grow the div
vertically?

This is a problem generated by a UI design requirement, so what about
looking
into the design?

--
Dag.
Aug 8 '05 #4
Dag Sunde wrote:
"Andrew Poulos" <ap*****@hotmail.com> wrote in message
news:42***********************@per-qv1-newsreader-01.iinet.net.au...
RobG wrote:
Andrew Poulos wrote:
Say I have a text area. When the user clicks a button the entered text
displays in a DIV. If there's too much text to fit in that DIV then the
overflow text (the text that doesn't fit in the first DIV) displays in
an adjacent DIV.

Is there a way to know if there's "overflowing" text and, if there is,
if there a way to know what that text is?

Andrew Poulos
You could look at the innerHTML of the second div or look for text nodes
with values other than empty strings.

But there is likely some other way related to however you are doing the
overflow.


Sorry, I think I've not explained it correctly. Text will only go into
the second DIV if it doesn't fit in the first. So my question is
reworded to, given a DIV of a known size and how can I know how much
text will fit in it before it overflows?

I'm happy enough to count lines and words per line but I don't know
where the overflow occurs.

You can't, unless you hardcode the font size, *and* use a mono-spaced font
(i.e. Courier). And then only if you examine the exact pixel height and
width for that particular size up front.

Can't you solve this another way instead? Autoscroll? Grow the div
vertically?

This is a problem generated by a UI design requirement, so what about
looking into the design?


I understand but I was kind of hoping that as a DIV set to overflow:auto
"knows" when its contents overflow that there might be a way for
javascript to detect it.

Andrew Poulos
Aug 8 '05 #5


Andrew Poulos wrote:

I understand but I was kind of hoping that as a DIV set to overflow:auto
"knows" when its contents overflow that there might be a way for
javascript to detect it.


I would think that
divElement.scrollHeight
is larger than
divElement.offsetHeight
if content overflows so detecting that content overflows should be
possible. But identifying and moving the contents that overflows is
another story.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 8 '05 #6
"Andrew Poulos" <ap*****@hotmail.com> wrote in message
news:42***********************@per-qv1-newsreader-01.iinet.net.au...
Say I have a text area. When the user clicks a button the entered text
displays in a DIV. If there's too much text to fit in that DIV then the
overflow text (the text that doesn't fit in the first DIV) displays in
an adjacent DIV.

Is there a way to know if there's "overflowing" text and, if there is,
if there a way to know what that text is?


Not really, at least none that I've heard of, but there are various ways to
hack it.

One way would be to have two or more copies of the text inside clipping
elements.
The 1st element has the text positioned at the top, the 2nd has the text
positioned above the top of the clipping element by the same value as the
height of the 1st element.

I've used 'px' for the size and position rather than 'em' so you can change
the font size and see the apparent reflowing of text into the 2nd box. It's
a quick lash-up but seems to work.

eg:
<!-- FIRST BOX -->
<div style="overflow:hidden; width:200px; height:400px; position:absolute;
top:0; left:0">
<p style="position:relative; top:0"> --- placeholder text --- </p>
</div>

<!-- OVERFLOW BOX -->
<div style="overflow:hidden; width:200px; height:400px; position:absolute;
top:0; left:200px">
<p style="position:relative; top:-400px"> --- placeholder text --- </p>
</div>
Aug 8 '05 #7

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

Similar topics

15
by: Andrew Fedoniouk | last post by:
I have a simple test document which produce the following in Mozilla and Opera: http://terrainformatica.com/w3/p2/problem1.png Internet Explorer behaves as per recommendation (I guess) Did I...
6
by: Kai Grossjohann | last post by:
I have a frame which is supposed to contain a list of links. The clickable area of each link comprises a picture followed by some text. I want the text to be cut at the right hand side when the...
19
by: Jim | last post by:
I have spent the past few weeks designing a database for my company. The problem is I have started running into what I believe are stack overflow problems. There are two tab controls on the form...
2
by: Robert McEuen | last post by:
Using Access 97, Windows XP I'm receiving a Numeric Field Overflow error during text import that I did not receive before I split my database. Another thread I found suggested that the cause of...
7
by: wij | last post by:
Hi: Is there better way of detecting multiplication overflow for type long than by using double precision of lldiv to verify the result? Thanks in advance. I.J.Wang
25
by: junky_fellow | last post by:
Is there any way by which the overflow during addition of two integers may be detected ? eg. suppose we have three unsigned integers, a ,b, c. we are doing a check like if ((a +b) > c) do...
8
by: Geoff Cox | last post by:
Hello, When using Internet Explorer, on networked PCs in a college, to view a page of mine with Javascript code in it the "stack overflow" error message appears. When I access the same file...
2
by: esteuart | last post by:
I need to get the right combination for a div to clip any text inside and allow vertical alignment. I only have this problem in FireFox. I have 3 divs nested within each other. The outer div has...
4
by: zzpat | last post by:
I have a box element that uses overflow: hidden and I want a link which at the bottom of the element to be visible. I can't make the link visible. Obviously I'm having problems so I was...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...

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.