Javascript DOM onresize Event via HTML Tag onresize attribute

Introduction

This example demonstrates how to assign an "onresize" event to a body element.

Try to resize the browser window.

View in separate window

<!DOCTYPE html>
<html>
<body onresize="myFunction()">
<p>Window resized <span id="demo">0</span> times.</p>

<script>
var x = 0;// ww  w.ja va  2 s  . com
function myFunction() {
  var txt = x += 1;
  document.getElementById("demo").innerHTML = txt;
}
</script>

</body>
</html>
Bubbles: No
Cancelable: No
Event type: UiEvent if generated from a user interface, Event otherwise
Supported HTML tags: <body>



PreviousNext

Related