I have a HTML file which displays simple static content but I would like to display a number of youtube videos in iframes
on this document, and I do know how to do this.
What I want is to prevent these from loading ( and just display the static content ) if the browser is not connected to the internet. Is there any way to do this.
I can use HTML, CSS, Javascript or jQuery
Asked
Active
Viewed 140 times
0

byronyasgur
- 4,627
- 13
- 52
- 96
-
1Do an XHR request to something and see whether is succeeds. – PeeHaa Mar 14 '13 at 20:33
-
2Even better you should do the same but inverted, show static content - and change it to videos if the xhr succeeds. – apelsinapa Mar 14 '13 at 20:34
2 Answers
0
Check out online/offline events and the navigator.onLine
property. If those are not available, you can only try to load the content and listen for errors (and view them only if loaded correctly).

Bergi
- 630,263
- 148
- 957
- 1,375
-
-
Depends on what you're implementing. For example, I don't think you get an error with an onload event for an Iframe in older versions of IE. – Diodeus - James MacFarlane Mar 14 '13 at 20:43
0
navigator.onLine returns true for active network connection and false for offline!

spaceman12
- 1,039
- 11
- 18