X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR BOOTSTRAP XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

onresize Event

Event Object Reference Event Object

Example

Execute a JavaScript when the browser window is resized:

<body onresize="myFunction()">

Try it yourself »

More "Try it Yourself" examples below.


Definition and Usage

The onresize event occurs when the size of an element has changed.

Tip: To get the size of an element, use the clientWidth, clientHeight, innerWidth, innerHeight, outerWidth, outerHeight, offsetWidth and/or offsetHeight properties.


Browser Support

Event
onresize Yes Yes Yes Yes Yes


Syntax

In HTML:

<element onresize="myScript">Try it

In JavaScript:

object.onresize=function(){myScript};Try it

In JavaScript, using the addEventListener() method:

object.addEventListener("resize", myScript);Try it

Note: The addEventListener() method is not supported in Internet Explorer 8 and earlier versions.


Technical Details

Bubbles: No
Cancelable: No
Event type: UIEvent
Supported HTML tags: <a>, <address>, <b>, <big>, <blockquote>, <body>, <button>, <cite>, <code>, <dd>, <dfn>, <div>, <dl>, <dt>, <em>, <fieldset>, <form>, <frame>, <h1> to <h6>, <hr>, <i>, <img>, <input>, <kbd>, <label>, <legend>, <li>, <object>, <ol>, <p>, <pre>, <samp>, <select>, <small>, <span>, <strong>, <sub>, <sup>, <table>, <textarea>, <tt>, <ul>, <var>


Examples

More Examples

Example

Using the addEventListener() method to attach the "resize" event on the window object.

window.addEventListener("resize", myFunction);

Try it yourself »


Event Object Reference Event Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook