473,216 Members | 1,288 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,216 software developers and data experts.

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

FLEB
30
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 1684
rnd me
427 Expert 256MB
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
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
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

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.