Skip to content

Instantly share code, notes, and snippets.

@infynyxx
Created November 22, 2010 20:00
Show Gist options
  • Save infynyxx/710561 to your computer and use it in GitHub Desktop.
Save infynyxx/710561 to your computer and use it in GitHub Desktop.
Connection Detection for Webkit Browsers http://infynyxx.com/connection_detection.html
<html>
<head>
<title>Wifi Detection</title>
<script>
//http://infynyxx.com/misc/connection_detection.html
window.onload = function() {
if (navigator.connection) {
var connection_mapper = {}, conn = navigator.connection;
connection_mapper[conn.UNKNOWN] = "Unknown Connection";
connection_mapper[conn.CELL_2G] = "2G connection";
connection_mapper[conn.CELL_3G] = "3G Connection";
connection_mapper[conn.WIFI] = "WIFI Connection";
connection_mapper[conn.ETHERNET] = "Ethernet Connection";
alert(connection_mapper[conn.type]);
}
}
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment