<input type="button" value="Display My Window Size" onclick="displayDimensions()">
<p id="text1"></p>
<input type="button" value="Hide text"
onclick="document.getElementById('text2').style.visibility='hidden'">
<input type="button" value="Show text"
onclick="document.getElementById('text2').style.visibility='visible'">
<p id="text2">NOW YOU SEE ME!</p>
function displayDimensions() {
var w = window.innerWidth
|| document.documentElement.clientWidth
|| document.body.clientWidth;
var h = window.innerHeight
|| document.documentElement.clientHeight
|| document.body.clientHeight;
var x = document.getElementById("text1");
x.innerHTML = "Browser inner window width: " + w + ", height: " + h + ".";
}
function changeText() {
document.open("text/html","replace");
document.write("<h2>And Now You Don't! Well... Sorta</h2>");
document.close();
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.