Created
March 10, 2016 11:47
-
-
Save Chrisedmo/aa8118a4f18512bf0517 to your computer and use it in GitHub Desktop.
Responsive Screen Size Checker
This file contains hidden or 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
// 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