Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > How To Display Line Number In Browser

Reply
Thread Tools

How To Display Line Number In Browser

 
 
A. Shiraz
Guest
Posts: n/a
 
      12-25-2006
Ok, here is a problem.

How would I display line numbers next a text displayed in a web
browser?


The problem is that web browsers wrap the text as desired
(automatically) so a word can be on line 5 in one sized browser and the
same word can spill over to line 6 in a differently sized browser.
Right? Ok!

But we can control this wrapping functionality by putting the text in a
table cell and restricting the size of the table, right? OK! but how do
we tell how the table will display the text? Meaning how do we know the
line number a certain word will fall in?

Here is an example. Supppose I have a passage "I want to find the line
number that the word IT is on, by line number I mean the line number
that the word IT will fall on when the browser displays the passage
wrapping this passage over three lines maybe four; the browser could
even display the sentence in a table which will ensure that the
sentence is displayed consistently but how will I know where IT will
fall in the table? Will IT fall on first line? given the size of the
table? will IT fall on the fourth? How to be able to know
programmatically the line number of the word IT will be located at?"

Now as the passage mentions how can I predict the line number that IT
will fall on when viewed on the browser screen EVEN if the display of
the passage is controlled by table size?

A

 
Reply With Quote
 
 
 
 
Alex Hunsley
Guest
Posts: n/a
 
      12-25-2006
A. Shiraz wrote:
> Ok, here is a problem.
>
> How would I display line numbers next a text displayed in a web
> browser?


Btw, this isn't really a Java question, there may be a more appropriate
newsgroup to post it to.

There may be a plugin out there to do something similar to what you're
wanting for Firefox, but that's just a very maybe....

I would add that if you're worrying about exact layout issues, and what
line a certain word appears on etc., then there may be much better ways
to get your end result. Why are you particularly interested in what line
a certain number appears on? What are you trying to do?

> The problem is that web browsers wrap the text as desired
> (automatically) so a word can be on line 5 in one sized browser and the
> same word can spill over to line 6 in a differently sized browser.
> Right? Ok!
>
> But we can control this wrapping functionality by putting the text in a
> table cell and restricting the size of the table, right? OK! but how do
> we tell how the table will display the text? Meaning how do we know the
> line number a certain word will fall in?


Well, you don't, basically. That's one of the nice things about
webbrowsers - they format the text and you don't have to worry about
that (usually).

lex
 
Reply With Quote
 
 
 
 
Oliver Wong
Guest
Posts: n/a
 
      12-29-2006
"A. Shiraz" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> Ok, here is a problem.
>
> How would I display line numbers next a text displayed in a web
> browser?
>
>
> The problem is that web browsers wrap the text as desired
> (automatically) so a word can be on line 5 in one sized browser and the
> same word can spill over to line 6 in a differently sized browser.
> Right? Ok!

[...]

Consider using pre-formatted text elements, such as <pre></pre>

- Oliver


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
display line number in JTextPane Fabrice Java 4 12-31-2008 03:36 PM
ECLIPSE -- no display of line's number in the exception's stacktrace !!!!! Sebastien Java 3 09-28-2006 11:16 AM
OT: Number Nine, Number Nine, Number Nine FrisbeeŽ MCSE 37 09-26-2005 04:06 PM
Read a file line by line with a maximum number of characters per line Hugo Java 10 10-18-2004 11:42 AM



Advertisments