I have a component that depends on browser events for online/offline events to let know the user when he is disconnected from the activity.
I was checking on firefox, an… (read more)
I have a component that depends on browser events for online/offline events to let know the user when he is disconnected from the activity.
I was checking on firefox, and for some reason Im not able to see the event been emitted when disabling the network (I did test it, turn it the wifi on/off).
in the image , there is side by side with chrome and firefox, so I know my event listener works, but doesnt seems like firefox is sending the events,
I have a js using same examples from the documentation,
has someone else notice this? , or is some sort of settings in firefox?, according to the documentation it should be supported by default,
my poc code->
<title>Online Offline</title>
<script type="text/javascript">
console.log(" ******** Online Offline in real time **********");
const handlerOnline = async () => {
console.log("online handler :: ", new Date().toISOString());
};
const handlerOffline = async () => {
console.log("offline handler :: ", new Date().toISOString());
};
window.addEventListener("online", () => handlerOnline(), false);
window.addEventListener("offline", () => handlerOffline(), false);
window.document.addEventListener("online", () => handlerOnline(), false);
window.document.addEventListener("offline", () => handlerOffline(), false);
window.onoffline = (event) => {
console.log("1:: The network connection has been lost.");
};
window.ononline = (event) => {
console.log("A:: online");
};
window.addEventListener("offline", (event) => {
console.log("2:: The network connection has been lost.");
}, false, true);
window.addEventListener("online", (event) => {
console.log("B:: online");
}, false, true);
window.addEventListener("offline", (event) => {
console.log("3:: The network connection has been lost.");
});
</script>