Question

After a text search in a WebView (Android) with JavaScript by means of window.find(text), using code from this SO post, is successful and the corresponding text is highlighted.

Unfortunately I am not succeeding in finding the code for removing that formatting. I tried various methods (some from StackOverflow) without success, neither works what I deem the right one:

document.designMode = 'on';
document.execCommand('RemoveFormat', false, null);
document.designMode = 'off';

How can I remove the formatting?

Était-ce utile?

La solution

I solved by a trick, removing the span elements that are added by execCommand HiliteColor (assigned an attribute to original spans present at load time, if any):

addedSpans[i].outerHTML=addedSpans[i]innerHTML
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top