---
title: "setFrame(_:for:completionHandler:)"
framework: webkit
role: symbol
role_heading: Instance Method
path: "webkit/wkwebextensionwindow/setframe(_:for:completionhandler:)"
---

# setFrame(_:for:completionHandler:)

Called to set the frame of the window.

## Declaration

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

```swift
optional func setFrame(_ frame: CGRect, for context: WKWebExtensionContext) async throws
```

## 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

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

## See Also

### Related Documentation

- [frame(for:)](webkit/wkwebextensionwindow/frame(for:).md)
- [screenFrame(for:)](webkit/wkwebextensionwindow/screenframe(for:).md)
