M
M
mosikus2019-10-28 09:20:29
React
mosikus, 2019-10-28 09:20:29

How to check the lack of Internet and show a stub?

Hello. I have an iframe in my project, when I turn off the Internet and go to the page with the iframe, I just get the error "Failed to open the web page (see 5db68823b052f453499842.jpeg
screenshot)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
IDONTSUDO, 2019-10-28
@mosikus

https://www.npmjs.com/package/react-detect-offline
try this

V
Vadim Bogomazov, 2019-10-28
@bogomazov_vadim

Presumably like this:
https://developer.mozilla.org/en-US/docs/Web/API/N...

if (navigator.onLine) {
  console.log('online');
} else {
  console.log('offline');
}

E
Evgeny Koryakin, 2019-10-28
@zettend

Google towards onLoad and onError in the JS reference .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question