<!--
{
  "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/WKWebExtensionController/didFocusWindow(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "c:objc(cs)WKWebExtensionController(im)didFocusWindow:"
  },
  "title" : "didFocusWindow(_:)"
}
-->

# didFocusWindow(_:)

Should be called by the app when a window gains focus to fire appropriate events with all loaded web extensions.

```
func didFocusWindow(_ focusedWindow: (any WKWebExtensionWindow)?)
```

## Parameters

`focusedWindow`

The window that gained focus, or \c nil if no window has focus or a window has focus that is not visible to extensions.

## Discussion

This method informs all loaded extensions of the focused window, ensuring consistent understanding across extensions.

If the intention is to inform only a specific extension, you should use the respective method on that extension’s context instead.

---

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)