Created
June 21, 2017 16:05
-
-
Save michael-hawker/f17c1e2a298cc5e24ea657a03afa2509 to your computer and use it in GitHub Desktop.
Windows 10 JavaScript Example which detects Internet Connection Properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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