---
title: "webView(_:didCreateJavaScriptContext:for:)"
framework: webkit
role: symbol
role_heading: Instance Method
path: "webkit/webframeloaddelegate/webview(_:didcreatejavascriptcontext:for:)"
---

# webView(_:didCreateJavaScriptContext:for:)

Notifies the delegate that a new JavaScript context has been created.

## Declaration

```swift
optional func webView(_ webView: WebView!, didCreateJavaScriptContext context: JSContext!, for frame: WebFrame!)
```

## Parameters

- `webView`: The view sending the message.
- `context`: The doc://com.apple.documentation/documentation/JavaScriptCore/JSContext representing the frame’s JavaScript window object.
- `frame`: The doc://com.apple.webkit/documentation/WebKit/WebFrame to which the context belongs.

## Discussion

Discussion If a delegate implements this method along with either webView(_:didClearWindowObject:for:) or webView:windowScriptObjectAvailable:, only webView:didCreateJavaScriptContext:forFrame: will be invoked. This lets the delegate implement multiple versions to maintain backwards compatibility with older versions of WebKit.
