UIWebView Text Highlighting solution

自古美人都是妖i 提交于 2019-12-05 06:48:34

问题


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 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.


回答1:


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.




回答2:


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

Good Luck



来源:https://stackoverflow.com/questions/7760268/uiwebview-text-highlighting-solution

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!