<html>
<body>
<p>Use the addEventListener() method to attach a "resize" event on the window object.</p>
<p>Try to resize the browser window.</p>
<p>Window resized <span id="demo">0</span> times.</p>
<script>
window.addEventListener("resize", myFunction);
var x = 0;
function myFunction() {
var txt = x += 1;
document.getElementById("demo").innerHTML = txt;
}
</script>
</body>
</html>