开发者

UIWebView Text Highlighting solution

开发者 https://www.devze.com 2023-04-13 01:32 出处:网络
Has anyone found a solution for highlighting user-selected blocks of text in a UIWebView? I have a partial solution in place, however I have been unable to get it to work when the 开发者_StackOverflo

Has anyone found a solution for highlighting user-selected blocks of text in a UIWebView?

I have a partial solution in place, however I have been unable to get it to work when the 开发者_StackOverflow社区selection includes multiple elements in the DOM. In that case, I can find and highlight the first element in the selection, but javascript seems unable to tell me where the end of the selection is in this case.

It may be that I just don't understand the selection objects completely. It's difficult to find good documentation on them.


You can use document.execCommand("HiliteColor"). I answered a similar question recently:

Making Selection & Adding tag dynamically in JavaScript

Regarding documentation, MDN is pretty good for Selection and Range, although it doesn't really go into detailed examples.


I found perfect solution for this issue.Follow This Link.

Good Luck

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号