How to remove and increase font size using WKWebView?

In Safari, you can increase and decrease the font size. How can I achieve the same effect using WKWebView?

+4
source share
2 answers

Codes suggested by Inna that worked, but stopped working with iOS10.3. I did some research and found that we need to change it a bit, just changing "%%" to one "%".

So, the JS code should be:

let js = "document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust='\(fontSize)%'"

I got this information from the Apple Developer Forum. https://forums.developer.apple.com/thread/51079

0
source

Suppose you have a fontUpdatedHeight integer that gives you the exact font.

​​:

NSString *jsString = [[NSString alloc] initWithFormat:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '%lu%%'",(unsigned long)fontUpdatedHeight];

NSString

[self.WKWebView stringByEvaluatingJavaScriptFromString:jsString];
+1

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


All Articles