How to make spellchecker work with UIWebView?

I am trying to configure UIWebView to check for some editable divs (show red underline).

let html = "<div id="content" spellcheck="true" contenteditable="true" style = 'width:200px;height:200px' Misspel</div>" self.messageWebView.loadHTMLString(html!, baseURL: nil) 

It doesn't seem to work. However, I noticed one strange behavior. If I manually click on the editable area and then press another button to turn off the focus, it begins to underline the words with errors:

enter image description here

I tried

 var mydiv = document.getElementById('content'); mydiv.focus(); setTimeout(function {....mydiv.blur();}, 1000); 

This does not cause spell checking. Only manually clicking on an element to make the div lose focus makes it work. I also tried WKWebVIew. Does not work. I tested it on iPhone 6s, 10.3.2 Any ideas are welcome.

+5
source share

Source: https://habr.com/ru/post/1272017/


All Articles