문제

I was wondering how I could run js if the user goes offline during the time that they are on my site.

What I'm planning on doing is notifying them so they know and can reconnect?

I was using offline.js, here: http://github.hubspot.com/offline/docs/welcome/, but that is too complex for what i'm building honestly.

도움이 되었습니까?

해결책

Listen for offline events on window:

window.addEventListener('offline', offlineHandler);

or if you want it more jQueryish,

$(document).on('offline', offlineHandler);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top