<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: -",
    "macOS: 26.0.0 -",
    "visionOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "WebKit",
  "identifier" : "/documentation/WebKit/WebPage/DialogPresenting/handleJavaScriptPrompt(message:defaultText:initiatedBy:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "s:6WebKit0A4PageC16DialogPresentingP22handleJavaScriptPrompt7message11defaultText11initiatedByAC0ghI6ResultOSS_SSSgAC9FrameInfoVtYaF"
  },
  "title" : "handleJavaScriptPrompt(message:defaultText:initiatedBy:)"
}
-->

# handleJavaScriptPrompt(message:defaultText:initiatedBy:)

A JavaScript `prompt()` function has been invoked.

```
@MainActor func handleJavaScriptPrompt(message: String, defaultText: String?, initiatedBy frame: WebPage.FrameInfo) async -> WebPage.JavaScriptPromptResult
```

## Parameters

`message`

The message provided by JavaScript.

`defaultText`

The initial text provided by JavaScript, intended to be displayed in some text entry field.

`frame`

Information about the frame whose JavaScript process initiated this call.

## Return Value

The result of handling the invocation; if the result is affirmative, the response will include some text returned to JavaScript.

---

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)