# Processing Web Page Content by Interacting with the System Clipboard ArkWeb provides the capability of interacting with the system clipboard to cut, copy, and paste various types of data through the following methods: the [Menu](web_menu.md) component, keyboard shortcuts, and [W3C clipboard API and events](https://www.w3.org/TR/clipboard-apis/). ## Using the Menu Component or Keyboard Shortcuts You can customize options in the menu. When a user selects a specific option, the [cut](../reference/apis-arkweb/arkts-basic-components-web-WebContextMenuResult.md#cut9), [copy](../reference/apis-arkweb/arkts-basic-components-web-WebContextMenuResult.md#copy9) and [copyImage](../reference/apis-arkweb/arkts-basic-components-web-WebContextMenuResult.md#copyimage9) APIs can be called to cut or copy the text, HTML or image data to the system clipboard. The [paste](../reference/apis-arkweb/arkts-basic-components-web-WebContextMenuResult.md#paste9) and [pasteAndMatchStyle](../reference/apis-arkweb/arkts-basic-components-web-WebContextMenuResult.md#pasteandmatchstyle20) APIs can be used to paste the data to the input area of the web page. For details about how to use the APIs provided by the **Menu** component, see [Processing Web Page Content Using the Menu Component](web_menu.md). When a device has a physical keyboard, a user can also use keyboard shortcuts **Ctrl+X** (cut), **Ctrl+C** (copy), and **Ctrl+V** (paste) to interact with the clipboard. > **NOTE** > > To access the clipboard content through the [paste](../reference/apis-arkweb/arkts-basic-components-web-WebContextMenuResult.md#paste9) and [pasteAndMatchStyle](../reference/apis-arkweb/arkts-basic-components-web-WebContextMenuResult.md#pasteandmatchstyle20) APIs, you need to [request permissions to access the pasteboard](../basic-services/pasteboard/get-pastedata-permission-guidelines.md) by requesting the **ohos.permission.READ_PASTEBOARD** permission. ## Using the W3C Asynchronous Clipboard API [Asynchronous clipboard API](https://www.w3.org/TR/clipboard-apis/#async-clipboard-api) provides the methods of reading and writing the system clipboard for you to implement the cutting, copying, and pasting functionalities in web applications. - Use **writeText** to write text content to the system clipboard. ```javascript // Write text content to the clipboard. await navigator.clipboard.writeText ("Text content"); ``` - Use **write** to write content of any type to the system clipboard. ```javascript // Write HTML content to the clipboard. const clipboardItem = new ClipboardItem({ 'text/html': new Blob (["HTML content"], { type: 'text/html' }) }); await navigator.clipboard.write([clipboardItem]); ``` - Use **readText** to read text from the system clipboard. ```javascript // Read text from the clipboard. const text = await navigator.clipboard.readText() ``` - Use **read()** to read any type of content from the system clipboard. ```javascript // Read HTML from the clipboard. const clipboardItems = await navigator.clipboard.read(); const htmlBlob = await clipboardItems[0].getType('text/html'); ``` > **NOTE** > > To access the clipboard content through the **read()** and **readText()** methods of the asynchronous API, you need to [request the permission to access the pasteboard](../basic-services/pasteboard/get-pastedata-permission-guidelines.md): **ohos.permission.READ_PASTEBOARD**. ```ts // xxx.ets import { webview } from '@kit.ArkWeb'; @Entry @Component struct WebComponent { controller: webview.WebviewController = new webview.WebviewController(); build() { Column() { Web({ src: $rawfile("clipboard.html"), controller: this.controller }) } } } ``` Loaded HTML: ```html
No content is copied or pasted.