Comprobar si está desconectado con AJAX-offline. js
| Autor: | renjithspace |
|---|---|
| Views Total: | 295 |
| Sitio oficial: | Ir a la web |
| Actualizado: | November 9, 2018 |
| Licencia: | MIT |
Vista prévia
Descripción
offline. js es una pequeña utilidad de JavaScript que rastrea el estado en línea y sin conexión usando una solicitud AJAX y le notifica cuando la red se desconecta.
Funcionamiento
Importe la biblioteca offline. js al documento HTML.
<script src="/js/offline.js"></script>
Cree un nuevo objeto sin conexión y personalice el mensaje de notificación & el tiempo de espera en milisegundos.
new Offline({
notify: 'Oops! You are now offline',
timeout: 5000,
}); Personalice los estilos de la notificación sin conexión.
.offline-blocker {
position: absolute;
width: 100vw;
height: 100vh;
top: 0;
left: 0;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
background: #fff;
opacity: 0.8;
text-align: center;
}





