<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.10.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "WebKit",
  "identifier" : "/documentation/WebKit/WKUIDelegate/webView(_:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "c:objc(pl)WKUIDelegate(im)webView:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:completionHandler:"
  },
  "title" : "webView(_:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:completionHandler:)"
}
-->

# webView(_:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:completionHandler:)

Displays a JavaScript confirm panel.

```
optional func webView(_ webView: WKWebView, runJavaScriptConfirmPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping @MainActor @Sendable (Bool) -> Void)
```

## Parameters

`webView`

The web view invoking the delegate method.

`message`

The message to be displayed.

`frame`

Information about the frame whose JavaScript process initiated this call.

`completionHandler`

The completion handler to call after the confirm panel has been dismissed. Pass <doc://com.apple.documentation/documentation/Swift/true> if the user chose OK, and pass <doc://com.apple.documentation/documentation/Swift/false> if the user chose Cancel.

## Discussion

For user security, implementations of this method should call attention to the fact that a specific website controls the content in this panel. A simple formula for identifying the controlling website is `frame.request.URL.host`. The panel should have two buttons, typically OK and Cancel.

---

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)