<!--
{
  "availability" : [
    "iOS: 18.4.0 -",
    "iPadOS: 18.4.0 -",
    "macCatalyst: 18.4.0 -",
    "macOS: 15.4.0 -",
    "visionOS: 2.4.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "WebKit",
  "identifier" : "/documentation/WebKit/WKWebExtensionWindow/setFrame(_:for:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "c:objc(pl)WKWebExtensionWindow(im)setFrame:forWebExtensionContext:completionHandler:"
  },
  "title" : "setFrame(_:for:completionHandler:)"
}
-->

# setFrame(_:for:completionHandler:)

Called to set the frame of the window.

```
optional func setFrame(_ frame: CGRect, for context: WKWebExtensionContext, completionHandler: @escaping ((any Error)?) -> Void)
```

## Parameters

`frame`

The new frame of the window, in screen coordinates.

`context`

The context in which the web extension is running.

`completionHandler`

A block that must be called upon completion. It takes a single error argument, which should be provided if any errors occurred.

## Discussion

On macOS, the implementation of both [`frame(for:)`](/documentation/WebKit/WKWebExtensionWindow/frame(for:)) and [`screenFrame(for:)`](/documentation/WebKit/WKWebExtensionWindow/screenFrame(for:)) are prerequisites. On iOS, iPadOS, and visionOS, only [`frame(for:)`](/documentation/WebKit/WKWebExtensionWindow/frame(for:)) is a prerequisite. Without the respective method(s), this method will not be called.

## See Also

[`frame(for:)`](/documentation/WebKit/WKWebExtensionWindow/frame(for:))

Called when the frame of the window is needed.

[`screenFrame(for:)`](/documentation/WebKit/WKWebExtensionWindow/screenFrame(for:))

Called when the screen frame containing the window is needed.



---

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)