Using the addEventListener() method to attach the "resize" event on the window object. - Javascript DOM Event

Javascript examples for DOM Event:onresize

Description

Using the addEventListener() method to attach the "resize" event on the window object.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p>Window resized <span id="demo">0</span> times.</p>

<script>
window.addEventListener("resize", myFunction);

var x = 0;//from ww  w. j a  v a2s .  c o  m
function myFunction() {
    var txt = x += 1;
    document.getElementById("demo").innerHTML = txt;
}
</script>

</body>
</html>

Related Tutorials