HTML event attribute onresize








The onresize attribute event is triggered when the browser window is resized.

What's new in HTML5

The onresize attribute is new in HTML5.

Syntax

<element onresize="script or Javascript function name">

Supported Tags

<body>

Browser compatibility

onresize Yes Yes Yes Yes Yes




Example

<!DOCTYPE html>
<html>
<!-- ww w . ja  va 2s.  co  m-->
<body onresize="myFunction()">

<p>resize the browser window.</p>

<script>
function myFunction() {
    alert("resized!");
}
</script>

</body>
</html>

Click to view the demo