Mouse Location to Text line or Text line to location

K

kuna.subramaniyam

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
 
T

Thomas 'PointedEars' Lahn

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
 
K

kuna.subramaniyam

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top