Skip to content

Instantly share code, notes, and snippets.

@mneuhaus
Last active December 23, 2015 08:49
Show Gist options
  • Save mneuhaus/6610253 to your computer and use it in GitHub Desktop.
Save mneuhaus/6610253 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title></title>
<script type="text/javascript">
window.onresize = function(){
var agent = navigator.userAgent;
var current_width = window.innerWidth;
var html = document.getElementsByTagName('html')[0];
if (agent.match(/Android.*Mobile|BlackBerry|iPhone|iPod|Opera Mini|IEMobile/i)) {
html.className = "mobile";
} else if (agent.match(/Android|iPad/i)) {
html.className = "tablet";
} else if (agent.match(/MSIE 8/i)){
html.className = "desktop ie8";
} else if (agent.match(/MSIE 9/i)){
html.className = "desktop ie9";
} else if (agent.match(/MSIE 10/i)){
html.className = "desktop ie10";
} else if (agent.match(/MSIE 11/i)){
html.className = "desktop ie11";
} else if (current_width < 481) {
html.className = "mobile";
} else if (current_width < 992) {
html.className = "tablet";
} else {
html.className = "desktop";
}
};
window.onresize();
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment