Skip to content

Instantly share code, notes, and snippets.

@eyecatchup
Last active April 10, 2016 21:55
Show Gist options
  • Save eyecatchup/f3408614000346aa9719ea54bdcbfba7 to your computer and use it in GitHub Desktop.
Save eyecatchup/f3408614000346aa9719ea54bdcbfba7 to your computer and use it in GitHub Desktop.
HTML demo page for the ononline and onoffline events, that updates an indicator to show whether or not the user is online. +++ Demo: https://rawgit.com/eyecatchup/f3408614000346aa9719ea54bdcbfba7/raw/b2f93dd9a54079d28b71eb98aed55401a2773299/ononline-onoffline.html +++ Docs: https://html.spec.whatwg.org/multipage/semantics.html#the-body-element:h…
<!DOCTYPE HTML>
<html>
<head>
<title>Online or offline?</title>
<script>
function update(status) {
document.getElementById('status').textContent = !!status ? 'Online' : 'Offline';
}
</script>
</head>
<body ononline="update(true)"
onoffline="update(false)"
onload="update(navigator.onLine)">
<p>This page updates an indicator to show whether or not the user is online:</p>
<p>You are: <span id="status">(Unknown)</span></p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment