Mouse Location to Text line or Text line to location

Discussion in 'Javascript' started by kuna.subramaniyam@gmail.com, Apr 11, 2008.

  1. Guest

    I have the following issue to solve:

    Feature:
    There is an html page that is generated server side with dynamic
    content (mostly text content). The users should have a feature to
    bookmark certain sections of the document for later reference.

    Issue:
    To accomplish this I need to have either of the following:

    1) Allow the user to drag and drop (or click and drop) bookmark icons
    and use AJAX to save the locations. When saving I need to save the
    line beside the bookmark as well. Is there a function in javascript
    that can map the mouse coordinates to the character positions or get
    the closest text chunk?

    2) Allow the user to highlight the text they want to bookmark and
    click on a button to bookmark (again use AJAX to save the info). When
    this is done, I need to place an icon beside the line. Is there a
    function in Javascript that can give absolute/relative locations given
    the selection?

    Thanks in advance
    , Apr 11, 2008
    #1
    1. Advertising

  2. wrote:
    > I have the following issue to solve:
    >
    > Feature:
    > There is an html page that is generated server side with dynamic
    > content (mostly text content). The users should have a feature to
    > bookmark certain sections of the document for later reference.
    >
    > Issue:
    > To accomplish this I need to have either of the following:


    Break, fly, wheel.

    You have to do no such things. Simply structure your document properly
    (this is possible even though it is dynamically generated) and add

    <a href="#foo" name="foo" id="foo">...</a>

    at the beginning of each section (`id' is optional);

    <hX><a ...>...</a></hX>

    with X in {1, 2, ..., 6} would be a good idea.

    Users can then bookmark this section without any requirement for client-side
    scripting or other technologies depending on that.


    PointedEars
    --
    Anyone who slaps a 'this page is best viewed with Browser X' label on
    a Web page appears to be yearning for the bad old days, before the Web,
    when you had very little chance of reading a document written on another
    computer, another word processor, or another network. -- Tim Berners-Lee
    Thomas 'PointedEars' Lahn, Apr 11, 2008
    #2
    1. Advertising

  3. Guest

    I do not have control over the dynamic content as it is user generated
    (self published). Bookmarking feature needs to be done on the client
    side as different users may choose to bookmark different text (ie: if
    the text is "abc def ghi", some user may want to bookmark "abc def"
    and another "abc"). And bookmarking is not restricted to sections.
    More than bookmarking the feature is like a "highlighter".

    are there any javascript functions that can translate mouse position
    to content position/line or vice versa? The simplest way would be to
    allow the user to higlight the text they want to bookmark and then
    have a button that bookmarks the currently selected section. the
    downside not knowing the xy position of where the current selection
    is.

    thanks for all your help
    , Apr 14, 2008
    #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. Davisro
    Replies:
    2
    Views:
    1,290
    Jim Corey
    Apr 23, 2004
  2. Max
    Replies:
    7
    Views:
    9,080
  3. Claus Atzenbeck
    Replies:
    1
    Views:
    1,064
    Claus Atzenbeck
    Nov 26, 2004
  4. =?Utf-8?B?am9qb2Jhcg==?=
    Replies:
    1
    Views:
    4,073
    wwwtar
    Oct 2, 2006
  5. tom arnall
    Replies:
    6
    Views:
    1,260
    Ian Shef
    Jan 18, 2007
Loading...

Share This Page