Instance Method

webView:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:completionHandler:

Displays a JavaScript confirm panel.

Declaration

- (void)webView:(WKWebView *)webView runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(BOOL result))completionHandler;

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 YES if the user chose OK, and pass NO 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.