目录

Displaying Web Page Dialog Boxes

In HTML, JavaScript can be used to create the following types of dialog boxes: window.alert(message), window.confirm(message), and window.prompt(message, defaultValue). These dialog boxes can be used to convey information, confirm operations, or request input from users.

Currently, ArkWeb does not provide default dialog boxes. To ensure that the dialog box of a web page can be used properly, the application needs to customize the dialog box through the onAlert, onConfirm, and onPrompt APIs.

Implementing the Alert Dialog Box

You can use window.alert() to display a dialog box that contains optional information. The alert dialog box is used to ensure that users can obtain certain information. When the alert dialog box is displayed, the user needs to click OK to continue the operation.

An application can listen for the alert method of a web page through the onAlert event and create a dialog box.

Implementing the Confirm Dialog Box

You can use window.confirm() to display a dialog box that contains optional messages and waits for the user to confirm or cancel it.

The confirm dialog box is used to check whether the user accepts an operation such as leaving a web page to prevent data loss.

An application can listen for the confirm method of a web page through the onConfirm event and create a dialog box.

Implementing the Prompt Dialog Box

You can use window.prompt() to display a dialog box and wait for the user to submit text or cancel the dialog box. The user needs to input a value and then click **OK **or Cancel. If OK is clicked, the input value is returned. If Cancel is clicked, null is returned.

The prompt box is used to prompt users to input a value, which is usually used in scenarios where users need to input a temporary password or verification code.

An application can listen for the prompt method of a web page through the onPrompt event and create a dialog box.

Required resource file string.json:

{
  "string": [
    {
      "name": "from",
      "value": "From"
    },
    {
      "name": "warn",
      "value": "Warning"
    },
    {
      "name": "notarize",
      "value": "OK"
    },
    {
      "name": "cancel",
      "value": "Cancel"
    },
    {
      "name": "info",
      "value": "Message"
    }
  ]
}