UIWebView文本突出显示解决方案 [英] UIWebView Text Highlighting solution
问题描述
有没有人找到一个解决方案来突出显示UIWebView中的 用户选择的 块文本?
I有一个部分的解决方案,但是当选择包括DOM中的多个元素时,我一直无法使它工作。在这种情况下,我可以找到并突出显示选择中的第一个元素,但是javascript似乎无法告诉我在这种情况下选择的结束位置。
可能是因为我完全不理解选择对象。这是很难找到他们良好的文档。
您可以使用 document.execCommand( HiliteColor )
。我最近回答了一个类似的问题:
关于文档,MDN非常适合 选择
和 Range
,尽管它没有详细列举详细的例子。
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.
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.
这篇关于UIWebView文本突出显示解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!