Horje
HTML onresize Event Attribute

Definition and Usage

The onresize attribute fires when the browser window is resized


Example of HTML onresize Event Attribute

Here executes a JavaScript when the browser window is resized.
index.html
Example: HTML
 <body onresize="myFunction()"> 

Output should be:

Example of HTML onresize Event Attribute

Browser Support of HTML onresize Event Attribute

Syntax of HTML onresize Event Attribute

<element onresize="script">

Attribute Values of HTML onresize Event Attribute

Value Description
script The script to be run on onresize

Technical Details of HTML onresize Event Attribute

Supported HTML tags:

How to execute a JavaScript when the browser window is resized

Here tries to resize the browser window

index.html
Example: HTML
<!DOCTYPE html>
<html>

<body onresize="myFunction()">

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

<script>
function myFunction() {
  alert("You have changed the size of the browser window!");
}
</script>

</body>
</html>

Output should be:

How to execute a JavaScript when the browser window is resized




html event attributes

Type:
Develop
Category:
Web Tutorial
Sub Category:
HTML Window Event Attributes
Uploaded by:
Admin


Read Article
https://develop.horje.com/learn/1434/reference