Class

WKUserScript

A WKUserScript object represents a script that can be injected into a webpage.

Declaration

class WKUserScript : NSObject

Topics

Initializing a Script

init(source: String, injectionTime: WKUserScriptInjectionTime, forMainFrameOnly: Bool)

Returns an initialized user script that can be added to a user content controller.

Inspecting Script Information

var source: String

The script’s source code.

var injectionTime: WKUserScriptInjectionTime

The time when the script should be injected into the webpage.

var isForMainFrameOnly: Bool

A Boolean value indicating whether the script should be injected only into the main frame (true) or into all frames (false).

Constants

enum WKUserScriptInjectionTime

The time when a user script should be injected into a webpage.

Relationships

Inherits From

See Also

Scripts

class WKUserContentController

A WKUserContentController object provides a way for JavaScript to post messages and inject user scripts to a web view.

class WKScriptMessage

A WKScriptMessage object contains information about a message sent from a webpage.

protocol WKScriptMessageHandler

A class conforming to the WKScriptMessageHandler protocol provides a method for receiving messages from JavaScript running in a webpage.