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

# webView(_:runBeforeUnloadConfirmPanelWithMessage:initiatedBy:)

Displays a confirmation panel containing the specified message before a window closes.

```
optional func webView(_ sender: WebView!, runBeforeUnloadConfirmPanelWithMessage message: String!, initiatedBy frame: WebFrame!) -> Bool
```

## Parameters

`sender`

The web view that sent the message.

`message`

The message to display in the panel.

`frame`

The web frame whose JavaScript initiated this call.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the user clicked the OK button; otherwise, <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

Use this method to include a message in the confirmation panel in addition to the message supplied by the webpage. The confirmation panel should contain OK and Cancel buttons.

---

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)