## How do I determine whether an application is a system application?
Applicable to: OpenHarmony 3.2 Beta 5 (API version 9)
**Solution**
Use **bundleManager.getApplicationInfo** (available only for system applications) to obtain application information, and check the value of **systemApp** in the information. The application is a system application if the value is **true**.
## How do I obtain the version code and version name of an application?
Applicable to: OpenHarmony 3.2 Beta 5 (API version 9)
**Solution**
Use **bundleManager.getBundleInfoForSelf\(\)** to obtain the bundle information, which contains the version code (specified by **BundleInfo.versionCode**) and version name (specified by **BundleInfo.versionName**) .
**Example**
```
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
[UIAbilityContext](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontext) and [AbilityInfo](../reference/apis/js-apis-bundleManager-abilityInfo.md#abilityinfo)
## How do I obtain the application version number, version name, and screen resolution?
Applicable to: OpenHarmony 3.2 Beta5
**Solution**
1. Obtain the bundle information from the **@ohos.bundle.bundleManager** module.
The bundle information contains the application version number and version name.
```
import bundleManager from '@ohos.bundle.bundleManager';
## Can I obtain the HAP information of other applications from the current application?
Applicable to: OpenHarmony 3.2 Beta (API version 9)
According to the OpenHarmony security design specifications, the SDK does not provide APIs for third-party applications to obtain bundle information (including but not limited to the application name and version number) of other applications.
## How do I determine whether an application is a system application?
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
Use **bundle.getApplicationInfo** to obtain the application information, and then check the value of **systemApp** in the information. The application is a system application if the value is **true**.
## Why do the isStatusBarLightIcon and isNavigationBarLightIcon attributes not take effect when window.setSystemBarProperties() is called?
## How do I obtain the DPI of a device?
Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
Applicable to: OpenHarmony 3.2 Beta5 (API version 9, stage model)
In effect, the **isStatusBarLightIcon** and **isNavigationBarLightIcon** attributes turn the font white when set to **true**. If **statusBarContentColor** is also set in **window.setSystemBarProperties()**, the **isStatusBarLightIcon** attribute does not take effect. Similarly, if **navigationBarContentColor** is set, the **isNavigationBarLightIcon** attribute does not take effect.
**Solution**
## How do I set the style of the system bar?
Import the **@ohos.display** module and call the **getDefaultDisplaySync\(\)** API.
Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9
**Example**
Import the **\@ohos.window** module, and call **window.setSystemBarProperties()**.
console.error('Failed to enable the full-screen mode. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data));
});
```
## How do I obtain the window width and height?
Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9
Applicable to: OpenHarmony SDK 3.2 Beta5 (API version 9, stage model)
Use **window.getProperties()** to obtain the window properties. The **windowRect** field in the properties specifies the window width and height.
**Solution**
Example:
Import the **@ohos.window** module, obtain a **Window** object, and use **getWindowProperties\(\)** of the object to obtain the window properties. The **windowRect** field in the properties specifies the window width and height.
**Example**
```ts
letpromise=windowClass.getProperties();
promise.then((data)=>{
console.info('Succeeded in obtaining the window properties. Data: '+JSON.stringify(data.windowRect));
}).catch((err)=>{
console.error('Failed to obtain the window properties. Cause: '+JSON.stringify(err));
});
```
## How do I set the color of the system bar?
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
## What should I do if the error message "npm ERR! code SELF_SIGNED_CERT_IN_CHAIN" is displayed?
Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
1. Run **npm config set strict-ssl=false** on the DevEco Studio terminal.
2. Run **npm install** on the DevEco Studio terminal.
## After manual updating of a DevEco Studio SDK, the error message "Cannot find module 'xxx\ets\x.x.x.x\build-tools\ArkTS-loader\node_modules\webpack\bin\webpack.js'" is displayed during HAP building. What should I do?
Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
1. Run **npm install** in the **ets\x.x.x.x\build-tools\ets-loader** directory of the SDK.
2. Run **npm install** in the **js\x.x.x.x\build-tools\ace-loader** directory of the SDK. Perform HAP building again.
## How do I pack a HAP file through the command line?
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
Method 1: Run **hvigor assembleHap**.
Method 2: In **scripts** of the project **package.json** file, define the build task script and run **npm buildOhosHaps**. The **buildOhosHaps** field can be customized.
```
"scripts": {
"buildOhosHaps": "hvigor assembleHap"
},
```
## How do I select API version 9 when creating a project in DevEco Studio?
Applicable to: DevEco Studio 3.0 Beta4 3.0.0.993(B06)
When creating a project in DevEco Studio, make sure you are on the **OpenHarmony** tab page.
## What should I do if no callback is received and no error code is returned for downloads?
Applicable to: all versions
1. Re-install hdc_std and set up the device connection again.
2. Run **hdc_std shell hilog -Q pidoff** to disable log log flow control.
## What should I do if the "error: unknow option. usage: aa start \<options>" message is displayed after I click Run in DevEco Studio?
Applicable to: OpenHarmony SDK 3.2.5.6, stage model of API version 9
This issue occurs when the parameter in the **aa** command is invalid and therefore the target application fails to be opened.
To fix this issue, use either of the following methods:
1. Make sure the SDK version and the OS version are the same.
2. Touch the application icon on the device to manually open the application.
## What should I do if "The hdc_std version of the SDK does not match the hdcd version of the device." message is displayed when I run an application in DevEco Studio?
Applicable to: OpenHarmony SDK 3.2.5.6, stage model of API version 9
This issue occurs when the hdc and hdcd versions do not match. Update Dev Eco Studio to 3.0.1.993 or later.
After the update, Dev Eco Studio will still indicate the version mismatch, but will not block the running.
## How do I add a custom .d.ts file to the OpenHarmony SDK?
Applicable to: OpenHarmony SDK 3.1.7.7, FA model of API version 8
Name the .d.ts file **@ohos.xxxx.d.ts**, save it to the SDK path, and restart Dev Eco Studio.
A code notification is displayed when the file is imported.
## How do I switch to the full SDK?
Applicable to: OpenHarmony SDK 3.2.7.5
Follow the instructions in [Guide to Switching to Full SDK](../quick-start/full-sdk-switch-guide.md).
## What are the restrictions on using generator functions in TypeScript?
Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
Below are the restrictions on using generator functions in TypeScript:
- Expressions can be used only in character strings (in the ${expression} format), **if** conditions, **ForEach** parameters, and component parameters.
- No expressions should cause any application state variables (including **@State**, **@Link**, and **@Prop**) to change. Otherwise, undefined and potentially unstable framework behavior may occur.
- The generator function cannot contain local variables.
None of the above restrictions apply to anonymous function implementations of event handlers (such as **onClick**).
Negative example:
```
build() {
let a: number = 1 // invalid: variable declaration not allowed
Column() {
Text('Hello ${this.myName.toUpperCase()}') // ok.
ForEach(this.arr.reverse(), ..., ...) // invalid: Array.reverse modifies the @State array variable in place
}
buildSpecial() // invalid: no function calls
Text(this.calcTextValue()) // this function call is ok.
}
```
## How do I dynamically replace the %s placeholder in a resource file?
Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
In an application, you can replace the %s placeholder by using the second parameter in **$r('app.string.xx')**, which is used to reference application resources.
Example:
```
build() {
//do something
// The second parameter indicates the referenced string resource, which can be used to replace the %s placeholder.
Text($r('app.string.entry_desc','aaa'))
.fontSize(100)
.fontColor(Color.Black)
//do something
}
```
## How do I read an XML file in Resource and convert data in it to the string type?
Applicable to: OpenHarmony SDK 3.2.2.5, stage model of API version 9
1. Obtain Uint8Array data by calling the **RawFile** API of **resourceManager**.
2. Convert the Uint8Array data to strings by calling the **String.fromCharCode** API.
## What should I do if the global static variables of a class do not work?
Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9
Objects imported to abilities and pages are packaged into two different closures, that is, two global objects. In this case, a static variable referenced by the abilities is not the same object as that referenced by the pages. Therefore, global variables cannot be defined by defining static variables in the class. You are advised to use AppStorage to manage global variables.
## How do I obtain resources in the stage model?
Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9
The stage model allows an application to obtain a **ResourceManager** object based on **context** and call its resource management APIs without first importing the required bundle. This method, however, is not applicable to the FA model.
Example:
```
const context = getContext(this) as any
context
.resourceManager
.getString($r('app.string.entry_desc').id)
.then(value => {
this.message = value.toString()
})
```
## How do I obtain data through an API before page loading?
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
In the **aboutToAppear** function, use an asynchronous API to obtain page data and **@State** to decorate related variables. After the data is obtained, the page is automatically refreshed based on the variables.
```
@Entry
@Component
struct Test6Page {
// After the data is obtained, the page is automatically refreshed.
@State message: string = 'loading.....'
aboutToAppear(){
// Simulate an asynchronous API to obtain data.
setTimeout(()=>{
this.message = 'new msg'
},3000)
}
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
```
## Do the worker thread and the main thread run in the same global context?
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
No. The worker thread and the main thread are not in the same global context. They interact with each other in data communication mode.
## Which API is used for URL encoding in OpenHarmony?
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
The global function **encodeURI** is used for URI encoding, and **decodeURI** is used for URI decoding. For example, a space character is encoded as %20.
## Does OpenHarmony provide any API for parsing XML files?
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
Yes. The **convert** API of the **convertxml** module can be used to convert XML text into JavaScript objects.
## How do I configure application icons to be used across devices?
Applicable to: OpenHarmony SDK 3.0, stage model of API version 9
Use resource qualifiers to configure application icons to be used across devices.
## Can placeholders be configured in the string.json file of the stage model?
Applicable to: OpenHarmony SDK 3.2.6.3, stage model of API version 9
The **string.json** file does not support placeholders. As an alternative, you can define variables on the target page and combine these variables and **Resource** objects.
## Is there any difference between the OpenHarmony API systemTime.getCurrentTime() and the JS API new Date().getTime() API?
Applicable to: OpenHarmony SDK 3.2.6.3, stage model of API version 9
Similar to **new Date().getTime()**, **systemTime.getCurrentTime(false)** returns the number of milliseconds that have elapsed since the Unix epoch. **systemTime.getCurrentTime(true)** returns the number of nanoseconds that have elapsed since the Unix epoch. The system time is used in both APIs.
## How do I define @BuilderParam decorated attributes based on the value assigned to them?
Applicable to: OpenHarmony SDK 3.2.6.5, stage model of API version 9
If no parameter is passed when assigning a value to the **@BuilderParam** decorated attribute (for example, **content: this.specificParam**), define the type of the attribute as a function without a return value (for example, **@BuilderParam content: () => voi**). If any parameter is passed when assigning a value to the **@BuilderParam** decorated attribute (for example, **callContent: this.specificParam1("111")**), define the type of the attribute as **any** (for example, **@BuilderParam callContent: any**).
## How does ArkTS convert a string into a byte array?
Applicable to: all versions
Refer to the following code:
```
function stringToByte(str) {
var bytes = new Array();
var len,c;
len = str.length;
for(var i = 0;i<len;i++) {
c = str.charCodeAt(i);
if( c >= 0x010000 && c<= 0x10FFFF) {
bytes.push(((c>>18) & 0x07) | 0xf0);
bytes.push(((c>>12) & 0x3F) | 0x80);
bytes.push(((c>>6) & 0x3f) | 0x80);
bytes.push((c & 0x3F) | 0x80);
} else if(c >= 0x000800 && c<= 0x00FFF){
bytes.push(((c>>12) & 0x07) | 0xf0);
bytes.push(((c>>6) & 0x3F) | 0x80);
bytes.push((c & 0x3F) | 0x80);
} else if(c >= 0x000800 && c<= 0x0007FF) {
bytes.push(((c>>6) & 0x3F) | 0x80);
bytes.push((c & 0x3F) | 0x80);
} else {
bytes.push(c & 0xFF)
}
}
return bytes;
}
```
## What do I do if the "Too many wokers, the number of worker exceeds the maximum" message is displayed during worker creation?
Applicable to: OpenHarmony SDK 3.2.6.5
An application allows for a maximum of seven workers. Therefore, use the **termiate** API to release workers when they are not needed.
## What is the difference between a @Builder decorated method and other methods?
Applicable to: OpenHarmony SDK 3.2.6.5, stage model of API version 9
If the **@Builder** decorated method uses a custom component, this component is re-created each time the method is called.
## Why is the callback registered through @Watch not triggered when the object attributes of an array change?
Applicable to: OpenHarmony SDK 3.2.6.5, stage model of API version 9
As with **@State**, the callback registered through **@Watch** can be used to listen for only one layer of data changes. If the object attributes of the array changes at the inner layer, the callback will not be triggered.
## How do I listen for in-depth changes of @State decorated variables?
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
To listen for in-depth changes of **@State** decorated variables, you can use **@Observed** and **@ObjectLink** decorators.
## How do I implement character string encoding and decoding?
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
You can use **TextEncoder** and **TextDecoder** provided by the **util** module.
Reference: [TextEncoder](../reference/apis/js-apis-util.md#textencoder) and [TextDecoder](../reference/apis/js-apis-util.md#textdecoder)
## How do i import and export namespaces?
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
- Exporting namespaces
```
namespace Util{
export function getTime(){
return Date.now()
}
}
export default Util
```
- Importing namespaces
```
import Util from './util'
Util.getTime()
```
## Can relational database operations be performed in the worker thread?
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
No. Relational database operations cannot be performed in the worker thread.
3. Process the obtained **PixelMap** object. For example, render and display the image.
## How do I apply for the media read/write permission on a device?
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
1. Configure the permissions **ohos.permission.READ_MEDIA** and **ohos.permission.WRITE_MEDIA** in the **module.json5** file.
Example:
```
{
"module" : {
"requestPermissions":[
{
"name" : "ohos.permission.READ_MEDIA",
"reason": "$string:reason"
},
{
"name" : "ohos.permission.WRITE_MEDIA",
"reason": "$string:reason"
}
]
}
}
```
2. Call **requestPermissionsFromUser** to request the permissions from end users in the form of a dialog box. This operation is required because the grant mode of both permissions is **user_grant**.
```
import abilityAccessCtrl from '@ohos.abilityAccessCtrl.d.ts';
let permissions: Array<string> = ['ohos.permission.READ_MEDIA','ohos.permission.WRITE_MEDIA']
let atManager = abilityAccessCtrl.createAtManager();
// context is the ability-level context of the initiator UIAbility.
## How do I obtain the frame data of a camera when using the XComponent to display the preview output stream of the camera?
Applicable to: OpenHarmony 3.2 (API version 9, stage model)
**Symptom**
Currently, the API does not support real-time preview of the camera frame data. To obtain the frame data, you must bind an action, for example, photographing.
**Solution**
Create a dual-channel preview to obtain the frame data.
## How do I obtain the preview image of the front camera?
Applicable to: OpenHarmony 3.2 (API version 9, stage model)
**Solution**
1. Use the **@ohos.multimedia.camera** module to obtain the physical camera information.
```
let cameraManager = await camera.getCameraManager(context);
let camerasInfo = await cameraManager.getSupportedCameras();
let cameraDevice = this.camerasInfo[0];
```
2. Create and start the input stream channel of the physical camera.
```
let cameraInput = await cameraManager.createCameraInput(cameraDevice);
await this.cameraInput.open();
```
3. Obtain the output formats supported by the camera, and create a preview output channel based on the surface ID provided by the XComponent.
```
let outputCapability = await this.cameraManager.getSupportedOutputCapability(cameraDevice);
let previewProfile = this.outputCapability.previewProfiles[0];
let previewOutput = await cameraManager.createPreviewOutput(previewProfile, previewId);
```
4. Create a camera session, add the camera input stream and preview output stream to the session, and start the session. The preview image is displayed on the XComponent.
```
let captureSession = await cameraManager.createCaptureSession();
await captureSession.beginConfig();
await captureSession.addInput(cameraInput);
await captureSession.addOutput(previewOutput);
await this.captureSession.commitConfig()
await this.captureSession.start();
```
## How do I set the camera focal length?
Applicable to: OpenHarmony 3.2 (API version 9, stage model)
**Solution**
1. Check whether the camera is a front camera. A front camera does not support focal length setting.
2. Use **captureSession.getZoomRatioRange\(\)** to obtain the focal length range supported by the device.
3. Check whether the target focal length is within the range obtained. If yes, call **captureSession.setZoomRatio\(\)** to set the focal length.
## How do I play music in the background?
Applicable to: OpenHarmony 3.2 (API version 9, stage model)
**Symptom**
Music cannot be played in the background.
**Solution**
**AVSession** controls media playback. When a third-party application switches to the background or encounters a screen lock event, media playback is forcibly paused and the application is unaware of the pause. To enable the application to continue the playback in the background, request a continuous task and access the AVSession capability, which allows Control Panel to control the playback behavior of third-party applications.
## Is there a native API that provides functions similar to Canvas?
Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
Yes. The native API **Drawing** provides similar functions. It can be used for 2D drawing.
## When a native HAP is running, the error message "Obj is not a valid object" is displayed for the imported namespace. What should I do?
Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
Check the **abiFilters** parameter value in the **build-profile.json5** file in the root directory of the module (not the root directory of the project). If the device is 32-bit, the value must be **armeabi-v7a**. If the device is 64-bit, the value must be **arm64-v8a**.
## What should I do when the error message "install parse profile prop check error" is displayed during the running of a native HAP?
Applicable to: OpenHarmony SDK 3.2.6.3, stage model of API version 9
Check the **abiFilters** parameter value in the **build-profile.json5** file in the root directory of the module (not the root directory of the project). If the device is 32-bit, the value must be **armeabi-v7a**. If the device is 64-bit, the value must be **arm64-v8a**.
## What should I do when the error message "undefined symbol: OH_LOG_Print" is displayed during log printing by **OH_LOG_Print**?
Applicable to: OpenHarmony SDK 3.2.6.3, stage model of API version 9
Modify the **CMakeLists.txt** file by adding **libhilog_ndk.z.so** to the end of **target_link_libraries**.
## How do I obtain the value of version in the package.json file of a module?
Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
1. In the script file **hvigorfile.js** of Hvigor, use **subModule.getPackageJsonPath** to obtain the location of the **package.json** file in the module.
2. Use Node.js to read the **version** field in the **package.json** file and write the value to the **buildOption.cppFlags** field in the **build-profile.json5** file.
const ohosPlugin = require('@ohos/hvigor-ohos-plugin').hapTasks(subModule) // The plug-in executes the C++ build task and reads the build-profile.json5 file.
## Are the APIs used for obtaining PPG and ECG sensor data open to individual developers?
Applicable to: OpenHarmony 3.1 Beta 5 (API version 9)
Data collected by the PPG and ECG sensors of wearable devices is personal privacy data. Therefore, relative APIs are not open to individual developers.
## How do I obtain available third-party libraries?
Applicable to: OpenHarmony 3.1 Beta 5 (API version 9)
The three-party and four-party libraries that can be obtained through ohpm are summarized in the [OpenHarmony-TPC/tpc_resource repository](https://gitee.com/openharmony-tpc/tpc_resource). You can access this repository, and find the desired component based on the directory index.
## Which third-party libraries are related to network requests?
Applicable to: OpenHarmony 3.1 Beta 5 (API version 9)
The following third-party libraries are related to network requests: [Axios](https://gitee.com/openharmony-sig/axios), httpclient, and okdownload. For details, see the [OpenHarmony-TPC/tpc_resource repository](https://gitee.com/openharmony-tpc/tpc_resource).
## How do I use ohpm to import third- and fourth-party libraries?
Applicable to: OpenHarmony 3.1 Beta 5 (API version 9)
**Solution**
- Method 1:
1. Open the **Terminal** window and run the following command to go to the **entry** directory:
```
cd entry
```
2. Run the following command to install a third-party library, for example, **dayjs**:
```
ohpm install dayjs
```
3. Add the following statement in the .js file to import the third-party library:
```
import dayjs from 'dayjs';
```
- Method 2:
1. Enter the **entry** directory of the project and open the **oh-package.json5** file.
2. Write the third-party library to be installed (for example, **dayjs**) in the **oh-package.json5** file.
```
{
"dependencies": {
"dayjs": "^1.10.4",
}
}
```
3. Open the **Terminal** window and run the following command to go to the **entry** directory:
```
cd entry
```
4. Run the following command to install the third-party library:
```
ohpm install
```
5. Add the following statement in the .js file to import the third-party library:
## What does the following error message mean: "Stage model module... does not support including OpenHarmony npm packages or modules in FA model. OpenHarmony build tasks will not be executed, and OpenHarmony resources will not be packed."
Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
The third- and fourth-party libraries are not yet compatible with the stage model of API version 9 and cannot be used.
## Can I transfer project-level dependencies?
Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
For example, if project A depends on project B and project B depends on project C, can project A directly use the APIs provided by project C?
No. Project A cannot directly use the APIs provided by project C. The project packing tool NPM does not support dependency transfer. To use the APIs provided by project C, you can add the dependency of project C to project A.
## How do I obtain available third-party libraries?
Applicable to: OpenHarmony SDK 3.2.6.5, stage model of API version 9
For details, see [Third-Party Components That Can Be Directly Used on OpenHarmony](https://gitee.com/openharmony-sig/third_party_app_libs).
## Which third-party libraries are related to network requests?
Applicable to: OpenHarmony SDK 3.2.6.5, stage model of API version 9
The [Axios](https://gitee.com/openharmony-sig/axios) library is related to network requests.
## How do I use NPM to import third- and fourth-party libraries?
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
- Method 1:
1. Open the **Terminal** window and run the following command to go to the **entry** directory:
```
cd entry
```
2. Run the following command to install a third-party package, for example, **dayjs**:
```
npm install dayjs --save
```
3. Add the following statement in the .js file to import the package:
```
import dayjs from 'dayjs';
```
- Method 2:
1. Enter the **entry** directory of the project and open the **package.json** file.
2. Write the third-party NPM package to be installed (for example, **dayjs**) in the **package.json** file.
```
{
"dependencies": {
"dayjs": "^1.10.4",
}
}
```
3. Open the **Terminal** window and run the following command to go to the **entry** directory:
```
cd entry
```
4. Run the following command to install NPM:
```
npm install
```
5. Add the following statement in the .js file to import the package:
## What is the domStorageAccess attribute of the \<Web> component used for?
Applicable to: OpenHarmony SDK 3.2.6.5, stage model of API version 9
The **domStorageAccess** attribute specifies whether to enable the DOM Storage API, which is disabled by default and provides **localStorage**, but not **sessionStorage**.
## How do I check the online status on the HTML page loaded by the \<Web> component?
Applicable to: OpenHarmony SDK 3.2.7.5, stage model of API version 9
1. Configure the **ohos.permission.INTERNET** and **ohos.permission.GET_NETWORK_INFO** application permissions.
2. Obtain the online status through **window.navigator.onLine** on the HTML page.
## What should I do if the UserAgent string cannot be used in concatenation before the initial HTML5 page loading by the \<Web> component?
Applicable to: OpenHarmony SDK 3.2.6.5, stage model of API version 9
By default, the **UserAgent** string is obtained through the **WebController**. A **WebController** object can control only one **\<Web>** component, and methods on the **WebController** can only be called by the **\<Web>** component bound to it. To concatenate the default **UserAgent** string and a custom string before the initial page loading, perform the following:
1. Use **@State** to define the initial **userAgent** and bind it to the **\<Web>** component.
2. In the **onUrlLoadIntercept** callback of the **\<Web>** component, use **WebController** to obtain the default **userAgent** string and modify the **userAgent** bound to the **\<Web>** component.
The code snippet is as follows:
```
@Entry
@Component
struct Index {
private controller: WebController = new WebController()
## Should the logic for loading the lottie animation be written in the onAppear or onReady function?
Applicable to: OpenHarmony SDK 3.2.6.5, stage model of API version 9
The logic for loading the lottie animation must be written in the **onReady** function. The **onReady** function is triggered when the canvas is ready, while the **onAppear** function is triggered when the canvas is displayed.
## Do I need to invoke the refresh API after invoking deleteJavaScriptRegister?
Applicable to: all versions
No. This operation is not needed.
## How do I pass data from a page to the \<Web> component?
Applicable to: OpenHarmony SDK 3.2.7.5, stage model of API version 9
1. Use **WebController** to create two message ports: message port 1 and message port 0.
2. Send message port 1 to the HTML side, which can then save and use the port.
3. Register a callback for message port 0 on the application side.
4. Use message port 0 on the application side to send messages to message port 1 on the HTML side.
letavoidAreaRect=data.regionTint[0].region;// data.regionTint is an array that contains the rectangle coordinates of the status bar and navigation bar.