你不知道的浏览器失去网络事件-offline

阅读 53

2022-02-25



获得网络事件

window.addEventListener('online', (event) => {

    console.log("You are now connected to the network.");

});

// ononline version

window.ononline = (event) => {

  console.log("You are now connected to the network.");

};

失去网络事件

// addEventListener version

window.addEventListener('offline', (event) => {

    console.log("The network connection has been lost.");

});

// onoffline version

window.onoffline = (event) => {

  console.log("The network connection has been lost.");

};


精彩评论(0)

0 0 举报