---
title: "openWindow(with:completionHandler:)"
framework: safariservices
role: symbol
role_heading: Type Method
path: "safariservices/sfsafariapplication/openwindow(with:completionhandler:)"
---

# openWindow(with:completionHandler:)

Opens a new window with the desired webpage.

## Declaration

```swift
class func openWindow(with url: URL, completionHandler: (@Sendable (SFSafariWindow?) -> Void)? = nil)
```

```swift
class func openWindow(with url: URL) async -> SFSafariWindow?
```

## Parameters

- `url`: The URL to navigate to. The URL scheme must be http or https.
- `completionHandler`: A block to call when the URL is loaded in a new window.

## Discussion

Discussion important: You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration: class func openWindow(with url: URL) async -> SFSafariWindow? For information about concurrency and asynchronous code in Swift, see Calling Objective-C APIs Asynchronously.

## See Also

### Working with Windows

- [getActiveWindow(completionHandler:)](safariservices/sfsafariapplication/getactivewindow(completionhandler:).md)
- [showPreferencesForExtension(withIdentifier:completionHandler:)](safariservices/sfsafariapplication/showpreferencesforextension(withidentifier:completionhandler:).md)
