Implements the WebResourceRequest object to obtain resource requests. For details about the sample code, see onErrorReceive.
The initial APIs of this component are supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
The initial APIs of this class are supported since API version 8.
The sample effect is subject to the actual device.
constructor()
Constructs a WebResourceRequest object.
System capability: SystemCapability.Web.Webview.Core
getRequestHeader(): Array<Header>
Obtains the information about the resource request header.
System capability: SystemCapability.Web.Webview.Core
Return value
| Type | Description |
|---|---|
| Array<Header> | Information about the resource request header. |
getRequestUrl(): string
Obtains the URL of the resource request.
System capability: SystemCapability.Web.Webview.Core
Return value
| Type | Description |
|---|---|
| string | URL of the resource request. |
isMainFrame(): boolean
Checks whether the resource request is for the main frame.
System capability: SystemCapability.Web.Webview.Core
Return value
| Type | Description |
|---|---|
| boolean | Whether the resource request is for the main frame. The value true indicates that the resource request is for the main frame, and false indicates the opposite. |
isRedirect(): boolean
Checks whether the resource request is redirected by the server.
System capability: SystemCapability.Web.Webview.Core
Return value
| Type | Description |
|---|---|
| boolean | Whether the resource request is redirected by the server. The value true indicates that the resource request is redirected by the server, and false indicates the opposite. |
isRequestGesture(): boolean
Checks whether the resource request is associated with a gesture (for example, a tap).
System capability: SystemCapability.Web.Webview.Core
Return value
| Type | Description |
|---|---|
| boolean | Whether the resource request is associated with a gesture (for example, a tap). The value true indicates that the resource request is associated with a gesture, and false indicates the opposite. |