Instance Method

stringByEvaluatingJavaScript(from:)

Returns the result of running a JavaScript script. Although this method is not deprecated, best practice is to use the evaluateJavaScript(_:completionHandler:) method of the WKWebView class instead.

Declaration

func stringByEvaluatingJavaScript(from script: String) -> String?

Parameters

script

The JavaScript script to run.

Return Value

The result of running the JavaScript script passed in the script parameter, or nil if the script fails.

Discussion

New apps should instead use the evaluateJavaScript(_:completionHandler:) method from the WKWebView class. Legacy apps should adopt that method if possible.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software