WebScriptObject
A WebScriptObject object is an Objective-C wrapper for a scripting object passed to your application from the scripting environment.
Declaration
class WebScriptObjectOverview
You can not create a WebScriptObject object directly. You get a window WebScriptObject object by sending windowScriptObject to your WebView object.
You can use key-value coding methods—for example, setValue:forKey: and valueForKey:—to get and set properties of a WebScriptObject object. You can also access properties by index using the setWebScriptValueAt(_:value:) and webScriptValue(at:) methods. Use the removeWebScriptKey(_:) method to remove a scripting object property.
Not all properties and methods of a class are exported. Use the doc://com.apple.documentation/documentation/objectivec/nsobject-swift.class/setvalue(_:forundefinedkey:) and doc://com.apple.documentation/documentation/objectivec/nsobject-swift.class/value(forundefinedkey:) methods to intercept access to properties that are not exported. Similarly, use the invokeUndefinedMethod(fromWebScript:withArguments:) method to intercept method invocations that are not exported.
If you want access to properties and methods defined in your own classes, use the methods in the WebScripting informal protocol to specify the properties and methods the class should export to WebKit’s JavaScript environment.
Use the callWebScriptMethod(_:withArguments:) and evaluateWebScript(_:) methods to execute scripts in the scripting environment.
Topics
Getting and setting properties
Executing scripts
Raising exceptions
Getting a string representation
Instance Methods
See Also
Related Documentation
- WebKit DOM Programming Topics
- WebKit Objective-C Programming Guide