1

How i can serialize a selection (in javascript) of text in webView (html page) and restore this selection after the user reload the application ?

Nadh
  • 6,987
  • 2
  • 21
  • 21
samir
  • 4,501
  • 6
  • 49
  • 76

2 Answers2

1

You could use the serializer module of my Rangy library. For a similar but more lightweight solution, you could use this code snippet by Martin Honnen.

Tim Down
  • 318,141
  • 75
  • 454
  • 536
  • i have tried to use your rangy in an iOS project bt it's not working ? How about the code of martin Honnen, i have not found it ? thanks – samir May 01 '12 at 22:14
  • Not working how? Martin Honnen's code can be found in the HTML source of the page I linked to. – Tim Down May 01 '12 at 23:49
  • Ok good, i have seen that he use xpath but my webView is dynamic, i think that this code will not work if the webView change it's content ? – samir May 02 '12 at 08:31
  • @iPhoneDev: Yes, that's true. Same is true of the Rangy serializer module. In which case, how do you expect your serialization to work? – Tim Down May 02 '12 at 08:32
  • I am developing an iOS application ( witch a book), i have many UIWebView in this application. the user can select a text and i would like to serialize the selection and store it in the server and later restore this selection, but the content of my webView can change. – samir May 02 '12 at 08:39
-3

Use the serialize function in jquery Demo in this fiddle

Vimalnath
  • 6,373
  • 2
  • 26
  • 47