How to display the plug on the website when there is no Internet connection?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
36 views
Hello!

Caught my eye one feature, which is used by the website VK and DNS (maybe other, but I have not met yet)

When you reload the page without Internet, there is a stub. Please share links to the man'ula, as such realize, if someone has already implemented such.

5bf44ff69ca8c697973568.jpeg5bf45002b35ef663150000.jpeg
by | 36 views

7 Answers

0 like 0 dislike
Please read, this is for you as an option https://developer.mozilla.org/ru/docs/Web/API/Navi...5bf482010d2a0303590990.png
by
0 like 0 dislike
Guys, this is not ping and not NavigatorOnLine, you can't do that, because the user can read the article, and you to him if you lose the Internet all broken off. This die works on sites whose content is loaded via ajax, without reloading the page. The die should be shown in case of unsuccessful ajax request for a page, and ideally, offer you to look at offline pages (pre-loaded into storage). If a website is not ajax, you can use the same NavigatorOnLine to check that if the site is offline, preventing the links you click, and show this die only if you click the link.
by
0 like 0 dislike
If you make an ajax request when off the Internet, then it terminates by timeout.
You can subscribe to the timeout event and show a pre-prepared plate.
xhr.ontimeout = function (e) { // show sign };

In the "normal" POST or GET request (link or form submit) it doesn't work, and a sign of disconnection will show you the browser itself.
lJJHkr.png
by
0 like 0 dislike
Most likely the service worker. How to do not know)
Or maybe it's the provider injected? No Internet at what level (disabled adapter, or network problems)?
by
0 like 0 dislike
Ajax scripts timer pull likely.
by
0 like 0 dislike
zaart hi. See the finished version https://codepen.io/nikitamarcius/pen/xYMJVE (native JS), it works on the proposed Your_Jesus version.
by
0 like 0 dislike
Service Worker it's called, Google...
by
110,608 questions
257,187 answers
0 comments
40,248 users