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

# webView(_:runJavaScriptTextInputPanelWithPrompt:defaultText:initiatedBy:)

Displays a JavaScript text input panel and returns the entered text.

```
optional func webView(_ sender: WebView!, runJavaScriptTextInputPanelWithPrompt prompt: String!, defaultText: String!, initiatedBy frame: WebFrame!) -> String!
```

## Parameters

`sender`

The web view that sent the message.

`prompt`

The message to display in the text input panel.

`defaultText`

Default placeholder text to display in the text field.

`frame`

The web frame whose JavaScript initiated this call.

## Return Value

The text entered by the user if the user clicks OK; otherwise, `nil`.

## Discussion

This method is used to provide an alternate text input panel when JavaScript code calls `prompt`. Delegates should visually indicate that this panel comes from JavaScript. The panel should contain an OK and a Cancel button, and an editable text field. If you do not implement this method, a JavaScript text input panel is displayed.

---

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)