Skip to content

Instantly share code, notes, and snippets.

@Chrisedmo
Created March 10, 2016 11:47
Show Gist options
  • Save Chrisedmo/aa8118a4f18512bf0517 to your computer and use it in GitHub Desktop.
Save Chrisedmo/aa8118a4f18512bf0517 to your computer and use it in GitHub Desktop.
Responsive Screen Size Checker
// Get visible window sizes
function displayWindowSize(){
var e=window.innerWidth,
t=window.innerHeight;
document.getElementById("dev").innerHTML=t+"x"+e;
}
// Create DIV
var div=document.createElement("div");
div.id="dev";
// Append and style DIV to top right
document.body.appendChild(div);
[].forEach.call(document.querySelectorAll("#dev"),
function(e){
e.style.color="red";
e.style.position="fixed";
e.style.top="0";
e.style.right="0";
e.style.fontWeight="bold";
});
// Insert window sizes into the DIV
window.onload=displayWindowSize;
// Update the window size on resize of window
window.addEventListener("resize",displayWindowSize,!1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment