| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/WebKit.framework |
| Availability | Available in Mac OS X v10.3.9 and later.
|
| Companion guide | |
| Declared in | WebScriptObject.h |
A WebScriptObject is an Objective-C wrapper for a scripting object passed to your application from the scripting environment.
You can not create a WebScriptObject directly. You get a window WebScriptObject 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. You can also access properties by index using the setWebScriptValueAtIndex:value: and webScriptValueAtIndex: methods. Use the removeWebScriptKey: method to remove a scripting object property.
Not all properties and methods of a class are exported. Use the setValue:forUndefinedKey: and valueForUndefinedKey: methods to intercept access to properties that are not exported. Similarly, use the invokeUndefinedMethodFromWebScript: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 Web Kit’s JavaScript environment.
Use the callWebScriptMethod:withArguments: and evaluateWebScript: methods to execute scripts in the scripting environment.
Raises an exception in the current script execution context.
+ (BOOL)throwException:(NSString *)exceptionMessage
Returns YES if successful, NO otherwise.
WebScriptObject.hReturns the result of executing a method in the scripting environment.
- (id)callWebScriptMethod:(NSString *)methodName withArguments:(NSArray *)args
This method returns the result of invoking a method, specified by methodName, with the arguments, specified by args, in the scripting environment. Returns WebUndefined if an exception is thrown in the JavaScript environment or the method has no return value.
WebScriptObject.hReturns the result of evaluating a script in the scripting environment.
- (id)evaluateWebScript:(NSString *)script
The format of the script is dependent on the target scripting environment. Returns WebUndefined if an exception is thrown in the JavaScript environment or there is no return value.
WebScriptObject.hReturns the JavaScript object corresponding to the receiver.
- (JSObjectRef)JSObject
The JavaScript object corresponding to the receiver in the JavaScriptCore C API.
Removes a property from a scripting environment.
- (void)removeWebScriptKey:(NSString *)key
This method removes a property, specified by key, from the receiver in the scripting environment.
WebScriptObject.hRaises a scripting environment exception in the context of the current object.
- (void)setException:(NSString *)exceptionMessage
WebScriptObject.hSets the value of a property (by index).
- (void)setWebScriptValueAtIndex:(unsigned)index value:(id)value
This method sets the property value at the index specified by index to value.
WebScriptObject.hReturns a string representation of the receiver.
- (NSString *)stringRepresentation
The coercion of non-string objects is dependent on the scripting environment.
WebScriptObject.hReturns the index value of a property (specified by index).
- (id)webScriptValueAtIndex:(unsigned)index
This method returns the value of the property at the index specified by index. Accessing property values by index is dependent on the scripting environment. Returns WebUndefined if an exception is thrown in the JavaScript environment.
WebScriptObject.h
Last updated: 2008-06-19