Mac Developer Library

Developer

WebKit Framework Reference WebScriptObject Class Reference

Options
Deployment Target:

On This Page
Language:

WebScriptObject

A WebScriptObject object is an Objective-C wrapper for a scripting object passed to your application from the scripting environment. More...

Inheritance


Conforms To


Import Statement


import WebKit @import WebKit;

Availability


Available in OS X v10.4 and later.
  • Returns the result of executing a method in the scripting environment.

    Declaration

    Swift

    func callWebScriptMethod(_ name: String!, withArguments args: [AnyObject]!) -> AnyObject!

    Objective-C

    - (id)callWebScriptMethod:(NSString *)name withArguments:(NSArray *)args

    Parameters

    name

    The name of the method to invoke.

    args

    The values to pass to the method.

    Return Value

    The return value of the method. Returns WebUndefined if an exception is thrown in the JavaScript environment or the method has no return value.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.3 and later.

  • Returns the result of evaluating a script in the scripting environment.

    Declaration

    Swift

    func evaluateWebScript(_ script: String!) -> AnyObject!

    Objective-C

    - (id)evaluateWebScript:(NSString *)script

    Parameters

    script

    The script to evaluate.

    Return Value

    The scripting object. 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.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.3 and later.

  • Raises an exception in the current script execution context.

    Declaration

    Swift

    class func throwException(_ exceptionMessage: String!) -> Bool

    Objective-C

    + (BOOL)throwException:(NSString *)exceptionMessage

    Parameters

    exceptionMessage

    The exception message.

    Return Value

    YEStrue if successful, NOfalse otherwise.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.3 and later.

  • Raises a scripting environment exception in the context of the current object.

    Declaration

    Swift

    func setException(_ description: String!)

    Objective-C

    - (void)setException:(NSString *)description

    Parameters

    description

    Description of the exception.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.3 and later.

  • Returns a string representation of the receiver.

    Declaration

    Swift

    func stringRepresentation() -> String!

    Objective-C

    - (NSString *)stringRepresentation

    Return Value

    The string representation of the receiver.

    Discussion

    The coercion of nonstring objects is dependent on the scripting environment.

    Import Statement

    import WebKit

    Availability

    Available in OS X v10.3 and later.