Can js trigger network offline mode?

problem description

is there any way for js to trigger the offline mode of the network

the environmental background of the problems and what methods you have tried

related codes

/ / Please paste the code text below (do not replace the code with pictures)

what result do you expect? What is the error message actually seen?

Mar.23,2022

I don't know if there is any code trigger, but it can be opened manually in the network panel of the chrome developer tool.


js is generally in listening network mode. When you trigger the network mode, you feel that a simple js cannot do


window objects have onoffline events, and you can capture network outages.
window.navigator.onLine can find out whether there is a current network connection.
but it should be that should not actively cut off the network.

Menu