Instance Method

evaluateScript:withSourceURL:

Executes the specified JavaScript code, treating the specified URL as its source location.

Declaration

- (JSValue *)evaluateScript:(NSString *)script withSourceURL:(NSURL *)sourceURL;

Parameters

script

The JavaScript source code to evaluate.

sourceURL

A URL to be considered as the script’s origin.

Return Value

The last value generated by the script. Note that a script can result in the JavaScript value undefined.

Discussion

Evaluating a script runs any top-level code and adds function or object definitions to the context’s global object.

The sourceURL parameter is informative only; debuggers may use this URL when reporting exceptions.

See Also

Evaluating Scripts

- evaluateScript:

Executes the specified JavaScript code.