Skip to content

Instantly share code, notes, and snippets.

@michael-hawker
Created June 21, 2017 16:05
Show Gist options
  • Save michael-hawker/f17c1e2a298cc5e24ea657a03afa2509 to your computer and use it in GitHub Desktop.
Save michael-hawker/f17c1e2a298cc5e24ea657a03afa2509 to your computer and use it in GitHub Desktop.
Windows 10 JavaScript Example which detects Internet Connection Properties
window.addEventListener("DOMContentLoaded", (ev) => {
if (typeof Windows !== 'undefined') {
var profile = Windows.Networking.Connectivity.NetworkInformation.getInternetConnectionProfile();
var connectivity = profile.getNetworkConnectivityLevel();
document.getElementById("connectionstatus").innerHTML = connectivity;
document.getElementById("hasinternet").innerHTML = (connectivity == Windows.Networking.Connectivity.NetworkConnectivityLevel.internetAccess);
document.getElementById("islan").innerHTML = profile.isWlanConnectionProfile;
document.getElementById("iswan").innerHTML = profile.isWwanConnectionProfile;
} else {
document.getElementsByTagName("body")[0].innerHTML = "Load within Windows Web App.";
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment