English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

Complete List of HTML Tags

HTML onresize Event Attribute

The resize event is triggered when the document view is adjusted in size.

HTML Event Attributes

Online Example

Execute JavaScript when adjusting the browser window size:

<!DOCTYPE html>
<html>
<head>
<title>HTML onresize Event Attribute Usage (Basic Tutorial Website oldtoolbag.com)</title>
</head>
<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>
Test and see ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

All major browsers support the onresize event attribute

Definition and Usage

The onresize attribute is triggered when the browser window size is adjusted.

The onresize attribute is commonly used to adjust the window size.

HTML 4.01 with HTML5differences

None.

Syntax

<element onresize="script">

Attribute Value

ValueDescription
scriptSpecifies the script to be executed when the onresize event is triggered.
HTML Event Attributes