Skip to content

Instantly share code, notes, and snippets.

@tieleman
Created March 14, 2013 09:43
Show Gist options
  • Save tieleman/5160086 to your computer and use it in GitHub Desktop.
Save tieleman/5160086 to your computer and use it in GitHub Desktop.
Quick 'n dirty script to report viewport sizes. See #5159984 for a list of devices.
<!DOCTYPE html>
<html>
<head>
<title>viewport test</title>
<meta name="viewport" id="viewport" content="width=device-width">
<meta charset="utf-8">
</head>
<body>
<span id="width"></span> x <span id="height"></span>
<script type="text/javascript">
(function() {
function calculate() {
for (var i=0; i<2560; i++) {
document.getElementById("width").innerText = i;
if (window.matchMedia("screen and (max-width: " + i + "px)").matches) {
break;
}
}
for (var i=0; i<2560; i++) {
document.getElementById("height").innerText = i;
if (window.matchMedia("screen and (max-height: " + i + "px)").matches) {
break;
}
}
}
calculate();
window.onorientationchange = calculate;
window.onresize = calculate;
})();
</script>
</body>
</html>
@tieleman
Copy link
Author

See https://gist.github.com/tieleman/5159984 for a list of devices and their reported sizes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment