Returns the result of running a JavaScript script. Although this method is not deprecated, best practice is to use the evaluate
method of the WKWeb
class instead.
SDKs
- iOS 2.0–12.0Deprecated
- Mac Catalyst 13.0–13.0Deprecated
Framework
- UIKit
Declaration
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 evaluate
method from the WKWeb
class. Legacy apps should adopt that method if possible.
Important
The string
method waits synchronously for JavaScript evaluation to complete. If you load web content whose JavaScript code you have not vetted, invoking this method could hang your app. Best practice is to adopt the WKWeb
class and use its evaluate
method instead.