Contents

stringByEvaluatingJavaScript(from:)

Returns the result of running a JavaScript script.

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.