---
title: WebScriptObject
framework: webkit
role: symbol
role_heading: Class
path: webkit/webscriptobject
---

# WebScriptObject

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

## Declaration

```swift
class WebScriptObject
```

## Overview

Overview 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 setValue(_:forUndefinedKey:) and 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

- [jsObject()](webkit/webscriptobject/jsobject().md)
- [removeWebScriptKey(_:)](webkit/webscriptobject/removewebscriptkey(_:).md)
- [webScriptValue(at:)](webkit/webscriptobject/webscriptvalue(at:).md)
- [setWebScriptValueAt(_:value:)](webkit/webscriptobject/setwebscriptvalueat(_:value:).md)

### Executing scripts

- [callWebScriptMethod(_:withArguments:)](webkit/webscriptobject/callwebscriptmethod(_:witharguments:).md)
- [evaluateWebScript(_:)](webkit/webscriptobject/evaluatewebscript(_:).md)

### Raising exceptions

- [throwException(_:)](webkit/webscriptobject/throwexception(_:).md)
- [setException(_:)](webkit/webscriptobject/setexception(_:).md)

### Getting a string representation

- [stringRepresentation()](webkit/webscriptobject/stringrepresentation().md)

### Instance Methods

- [jsValue()](webkit/webscriptobject/jsvalue().md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Inherited By

- [DOMObject](webkit/domobject.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Related Documentation

- [WebKit DOM Programming Topics](apple-archive/documentation/AppleApplications/Conceptual/SafariJSProgTopics.md)
- [WebKit Objective-C Programming Guide](apple-archive/documentation/Cocoa/Conceptual/DisplayWebContent.md)

### Incorporating Scripts (Legacy)

- [WebScripting](objectivec/webscripting.md)
- [WebUndefined](webkit/webundefined.md)
