Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to know connected internet in js

// example code
let Connected = window.navigator.onLine;
if (Connected) {
  alert('Connection available');
} else {
  alert('Connection not available');
}
Comment

how to check if connected to internet js

function getStatus() {
    const statusDisplay = document.getElementById("status");
    statusDisplay.textContent = navigator.onLine ? "Online" : "OFFline";
    if (statusDisplay.textContent === "Online") {
      console.log('Online');
    } else if (statusDisplay.textContent === "OFFline"){
      console.log('Offline');
    }
}
setInterval(getStatus, 2000);
Comment

PREVIOUS NEXT
Code Example
Javascript :: mui typography bold 
Javascript :: random id js 
Javascript :: regex to allow only numbers letters and hyphen 
Javascript :: addclass js vanilla 
Javascript :: regex get number inside parentheses 
Javascript :: react simbu 
Javascript :: how to fetch the selected value of dropdown jquery 
Javascript :: jquery check if div has a certain style 
Javascript :: modal.show jquery 
Javascript :: c3 json from string 
Javascript :: javascript get element width and height 
Javascript :: skip import angular 6 
Javascript :: automatically scroll to bottom of page 
Javascript :: javascript get attribute 
Javascript :: data structures for coding interviews in javascript 
Javascript :: load node by id drupal 8 
Javascript :: how to remove modal-backdrop fade in jquery 
Javascript :: jquery convert a string to an array 
Javascript :: javascript check format uuid 
Javascript :: copy text to clipboard javascript 
Javascript :: url validator javascript 
Javascript :: javascript angle equation of a line 
Javascript :: remove a class from all elements javascript 
Javascript :: javascript remove parentheses 
Javascript :: first child element javascript 
Javascript :: × MUI: makeStyles is not longer exported from @mui/material/styles. You have to import it from @mui/styles. 
Javascript :: nangular make window available 
Javascript :: angular rebuild 
Javascript :: get age using moment 
Javascript :: jquery get element id 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =