<!--
{
  "availability" : [
    "macOS: 10.3.0 - 10.14.0"
  ],
  "documentType" : "symbol",
  "framework" : "WebKit",
  "identifier" : "/documentation/WebKit/WebFrameLoadDelegate/webView(_:didCreateJavaScriptContext:for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "c:objc(pl)WebFrameLoadDelegate(im)webView:didCreateJavaScriptContext:forFrame:"
  },
  "title" : "webView(_:didCreateJavaScriptContext:for:)"
}
-->

# webView(_:didCreateJavaScriptContext:for:)

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

```
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 [`WebFrame`](/documentation/WebKit/WebFrame) to which the context belongs.

## Discussion

If a delegate implements this method along with either [`webView(_:didClearWindowObject:for:)`](/documentation/WebKit/WebFrameLoadDelegate/webView(_:didClearWindowObject:for:)) or [`webView:windowScriptObjectAvailable:`](/documentation/WebKit/WebFrameLoadDelegate/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.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)