目录

What should I do if the network status fails to be detected on the loaded HTML page?

Symptom

When window.navigator.onLine is used on the HTML page to obtain the network status, the value is false no matter the network connection is set up or not.

Solution

Request the ohos.permission.GET_NETWORK_INFO permission for the application. This permission allows an application to obtain network information.

Reference

ohos.permission.GET_NETWORK_INFO