How To Display Line Number In Browser

Discussion in 'Java' started by A. Shiraz, Dec 25, 2006.

  1. A. Shiraz

    A. Shiraz Guest

    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
     
    A. Shiraz, Dec 25, 2006
    #1
    1. Advertising

  2. A. Shiraz

    Alex Hunsley Guest

    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
     
    Alex Hunsley, Dec 25, 2006
    #2
    1. Advertising

  3. A. Shiraz

    Oliver Wong Guest

    "A. Shiraz" <> wrote in message
    news:...
    > 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
     
    Oliver Wong, Dec 29, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Fabrice
    Replies:
    4
    Views:
    17,424
    praitheesh
    Dec 31, 2008
  2. Hugo
    Replies:
    10
    Views:
    1,320
    Matt Humphrey
    Oct 18, 2004
  3. Sebastien
    Replies:
    3
    Views:
    8,589
    chinnaswamyg
    Sep 28, 2006
  4. chinnaswamyg
    Replies:
    0
    Views:
    657
    chinnaswamyg
    Sep 28, 2006
  5. Kim Haines
    Replies:
    3
    Views:
    270
    Janwillem Borleffs
    Sep 8, 2003
Loading...

Share This Page