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

# webView(_:setFrame:)

Sets the frame rectangle of a web view’s window to the specified frame size.

```
optional func webView(_ sender: WebView!, setFrame frame: NSRect)
```

## Parameters

`sender`

The web view that sent the message.

`frame`

The frame size.

## Discussion

The sender invokes this method instead of setting the window’s frame directly, allowing delegates to augment the behavior by, for example, saving the original window size before resizing as a result of JavaScript running. If you do not implement this method, the `NSWindow` method <doc://com.apple.documentation/documentation/AppKit/NSWindow/setFrame(_:display:)> is sent to the window that contains `sender`, with <doc://com.apple.documentation/documentation/Swift/true> passed as the display argument.

---

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)