onresize = myFunction(); - Javascript DOM Event

Javascript examples for DOM Event:Element Event Attribute

Description

The onresize event occurs when the browser window has been resized.

Summary

Bubbles No
Cancelable No
Supported HTML tags: <body>

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

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

<script>
document.getElementsByTagName("BODY")[0].onresize = function() {myFunction()};

var x = 0;/*from  w  w w  . j  av  a 2s. com*/
function myFunction() {
    var txt = x += 1;
    document.getElementById("demo").innerHTML = txt;
}
</script>

</body>
</html>

Related Tutorials