Skip to main content
added 168 characters in body
Source Link

JavaScript ES6, 7171 43 bytes

fetch``.then(a=>alert(1)).catch(a=>alert``) 

Alerts 1 if online, alerts an empty string if offline. Thanks to Patrick Roberts for helping me shave off some bytes

Old version

_=>fetch('http://enable-cors.org').then(a=>alert(a)).catch(a=>alert(0)) 

Alerts [object Reponse] if online, alerts 0 if offline

f=_=>fetch('http://enable-cors.org').then(a=>alert(a)).catch(a=>alert(0)) f();

Removed the code snippet, it doesn't work because it loads from a different domain without CORS, but it works in the browser console

JavaScript ES6, 71 bytes

_=>fetch('http://enable-cors.org').then(a=>alert(a)).catch(a=>alert(0)) 

Alerts [object Reponse] if online, alerts 0 if offline

f=_=>fetch('http://enable-cors.org').then(a=>alert(a)).catch(a=>alert(0)) f();

JavaScript ES6, 71 43 bytes

fetch``.then(a=>alert(1)).catch(a=>alert``) 

Alerts 1 if online, alerts an empty string if offline. Thanks to Patrick Roberts for helping me shave off some bytes

Old version

_=>fetch('http://enable-cors.org').then(a=>alert(a)).catch(a=>alert(0)) 

Alerts [object Reponse] if online, alerts 0 if offline

Removed the code snippet, it doesn't work because it loads from a different domain without CORS, but it works in the browser console

deleted 3 characters in body
Source Link

JavaScript ES6, 71 bytes

_=>fetch('http://enable-cors.org').then(a=>alert(a)).catch(a=>alert(0)) 

Alerts [object Reponse] if online, alerts 0 if offline

f=_=>fetch('http://enable-cors.org').then(a=>alert(a.ok)).catch(a=>alert(0)) f();

JavaScript ES6, 71 bytes

_=>fetch('http://enable-cors.org').then(a=>alert(a)).catch(a=>alert(0)) 

Alerts [object Reponse] if online, alerts 0 if offline

f=_=>fetch('http://enable-cors.org').then(a=>alert(a.ok)).catch(a=>alert(0)) f();

JavaScript ES6, 71 bytes

_=>fetch('http://enable-cors.org').then(a=>alert(a)).catch(a=>alert(0)) 

Alerts [object Reponse] if online, alerts 0 if offline

f=_=>fetch('http://enable-cors.org').then(a=>alert(a)).catch(a=>alert(0)) f();

added 11 characters in body
Source Link

JavaScript ES6, 7471 bytes

_=>fetch('http://enable-cors.org').then(a=>alert(a.ok)).catch(a=>alert(0)) 

Alerts true[object Reponse] if online, alerts 00 if offline

f=_=>fetch('http://enable-cors.org').then(a=>alert(a.ok)).catch(a=>alert(0)) f();

JavaScript ES6, 74 bytes

_=>fetch('http://enable-cors.org').then(a=>alert(a.ok)).catch(a=>alert(0)) 

Alerts true if online, alerts 0 if offline

f=_=>fetch('http://enable-cors.org').then(a=>alert(a.ok)).catch(a=>alert(0)) f();

JavaScript ES6, 71 bytes

_=>fetch('http://enable-cors.org').then(a=>alert(a)).catch(a=>alert(0)) 

Alerts [object Reponse] if online, alerts 0 if offline

f=_=>fetch('http://enable-cors.org').then(a=>alert(a.ok)).catch(a=>alert(0)) f();

Source Link
Loading