How i can serialize a selection (in javascript) of text in webView (html page) and restore this selection after the user reload the application ?
Asked
Active
Viewed 1,545 times
1
-
2What do you mean by serializing text? – Nadh Apr 30 '12 at 14:43
-
@NADH It's not serializing text, it's serializing a selection (meaning the user's highlighted selection). – Tim Down Apr 30 '12 at 15:27
2 Answers
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