Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WKWebview stringByEvaluatingJavaScriptFromString equivalent? [duplicate]

UIWebview has (had?) an extremely useful function that enabled access to javascript variables from Swift.

func stringByEvaluatingJavaScriptFromString(_ script: String) -> String?

Does WKWebview have an equivalent function or idiom enabling access to javascript variables from Swift?

like image 324
lolololol ol Avatar asked Jul 06 '19 02:07

lolololol ol


1 Answers

Yes, WKWebView Also Have EvaluateJavaScript Method that enables you to run javascript code and access to javascript variables.

func evaluateJavaScript(_ javaScriptString: String, 
  completionHandler: ((Any?, Error?) -> Void)? = nil)
like image 153
Shin Avatar answered Nov 02 '22 10:11

Shin