HTML onresize Event Attribute

Example

Execute a JavaScript when the browser window is resized:

<body onresize="showMsg()">

Try It Yourself

Browser Support

IE Firefox Chrome Safari Opera

All major browsers support the onresize attribute.

Definition and Usage

onresize occurs when an object is resized.

onresize is often used when the browser window is resized.

Differences between HTML 4.01 and HTML5

None.

Syntax

<element onresize="script">

Attribute Value

Value Description
script Script executed when onresize occurs.