码迷,mamicode.com
首页 > Windows程序 > 详细

[PWA] Check Online Status by using the NavigatorOnLine API

时间:2018-07-02 21:29:19      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:could   status   https   ble   orm   nali   use   mes   color   

Even if you have your application fully cached, you couldn’t perform any external request without internet connection. That’s why in order to build an offline-capable application, you must know when it’s actually offline.

This lesson shows you how to use the NavigatorOnLine API and online/offline events in order to disable the functionality to send messages of the application.

 

    this.online = navigator.onLine
    window.addEventListener(‘online‘, () => (this.online = true))
    window.addEventListener(‘offline‘, () => {
      this.online = false
    })

 

[PWA] Check Online Status by using the NavigatorOnLine API

标签:could   status   https   ble   orm   nali   use   mes   color   

原文地址:https://www.cnblogs.com/Answer1215/p/9255725.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!