2

How can I save a range (based on user selection) and reload it the next time the user visit my page again?

Details: the user selects a portion of text and I highlight it with a span. Now I have to save the "coordinates" of the selected text, so the next time the user visits my page, I'll load the range coordinates from my db and highlight the text with a span.

Tony Mobile
  • 677
  • 8
  • 19

3 Answers3

1

Take a look at the Rangy library. It will do what you want, and more. You can take a look at the Serializer module and also the Highlighter module (this module is still in alpha, and so it may be unstable).

Vivin Paliath
  • 94,126
  • 40
  • 223
  • 295
0

Some similar answers:

Also (self-promotion alert) you could try Rangy's highlighter module.

Community
  • 1
  • 1
Tim Down
  • 318,141
  • 75
  • 454
  • 536
0

If you are using html5, you could use the Web Storage API.

Take a loop: http://www.w3schools.com/html/html5_webstorage.asp

Thiago Custodio
  • 17,332
  • 6
  • 45
  • 90