473,785 Members | 2,829 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 "overflowin g" text and, if there is,
if there a way to know what that text is?

Andrew Poulos
Aug 8 '05 #1
6 9162
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 "overflowin g" 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 "overflowin g" 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*****@hotmai l.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 "overflowin g" 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*****@hotmai l.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 "overflowin g" 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.scro llHeight
is larger than
divElement.offs etHeight
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*****@hotmai l.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 "overflowin g" 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:absolu te;
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:absolu te;
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
4838
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 miss something and width of paragraph can be set less than its content (without overflow specification)? Document is here: http://terrainformatica.com/w3/p2/problem1.htm
6
19411
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 user resizes the frame to be "too narrow". Right now, the source for that frame looks like this: <table border="1" width="100%"> <tr style="background-color:#C0C0C0">
19
3145
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 (nested), three list views, one tree control with up to 30,000 nodes, maybe 15 comboboxes (half of which have a large recordset as rowsource), 20 or so buttons and around 30 text boxes (not to mention the images, labels, etc and around 1000 lines...
2
8678
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 this error might be due to columns on the text file being in a different order than fields in the destination table, but they're the same in my case. I'm thinking a workaround might be to import to a temp table in the front-end, run an append...
7
2425
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
6276
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 something;
8
2036
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 from my home PC no such message. Is it possible for this to be caused by any IE setting?
2
15569
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 display of table, the first inner div has display of table-cell and the inner-most div has the text. The outer div has a set width and height. So here's the problem: Without the inner divs having a width and height set, the overflow:hidden doesn't...
4
2869
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 wondering if there's anything other than overflow : hidden that will give me an absolute 'height' and make the link visible. Pat
0
9645
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10151
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10092
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3647
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.