473,466 Members | 1,290 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

JS (or JQuery): Find the point where a line wraps

FLEB
30 New Member
Is there a built-in function or a simplified method to tell where a given line of text wraps/will wrap in a given container (the container is fixed-width)? I want to chop off and add an ellipsis to some text at the point where it exceeds one line.

My best idea so far is to just create a dummy container with the same specs, off-screen or invisible, and feed words into it one-by-one, then return where the container changes height. This just seems like the "brute force" long way around the problem, but I don't know if there's a better way.
Oct 2 '08 #1
2 1692
rnd me
427 Recognized Expert Contributor
that's the trick i use, and it works.

there really is no other good way since firefox 3 zooms everything, making
calculations next to impossible.

i would write it into a reusable function that you can pass text and a style attrib to, and get back the width.

makes a nice addition to your script library.
Oct 2 '08 #2
FLEB
30 New Member
Excellent. Thanks.

________________________________
Oct 7 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: RiGGa | last post by:
Hi, I have a html file that I need to process and it contains text in this format: <TD><SPAN class=xf id=EmployeeNo title="Employee Number">0123456</SPAN></TD></TR> (Note split over two...
1
by: joe shaboo | last post by:
HI, I'm new to Perl. I'm trying to write a simple script which will comment out a domain in my named.conf file for Bind. What I would like to do, is write a script which will comment out a...
1
by: chris | last post by:
Does anyone know any on-line C# exam which can give me a quick self-evaluation? Thanks a lot Chris
2
by: Burt | last post by:
I'm pulling back contact data from Exchange using WebDAV. The problem is a third party app is adding random "\r\n"s within the XML data, corrupting it. I want to remove these, but only if they...
2
by: youpak2000 | last post by:
What you can't find in programing text books Professional software development needs more knowledge than language syntax, OOP, styles, etc. There are many things which people usually learn by...
8
by: Harris Kosmidis | last post by:
It seems I cannot understand CSS, well. I have donw the following page: http://www.pennias.gr/home.php It's in greek but the context is of no importance. I used a big table to put in my page...
1
by: renu | last post by:
Hello, I have drawn polygon on window. And I want to check wheather given point is in that polygon region or not? How shold I find that? I have created object of class region GraphicsPath path...
2
by: asmpic | last post by:
Hi, I stumbled upon a script on the internet that monitors disk space and if it reaches a certain percentage being full it send an email. However, the problem I encountered was that one of the file...
53
by: Gianni Mariani | last post by:
Do you have a preference on maximum line width for C++ code? I've seen the craziest debates on this most silly of topic. I have witnessed engineers spent oodles of time fiddling with line...
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:
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...
1
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...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.