Jump to content

resize event handling


Recommended Posts

Although the documentation ( http://www.w3schools.com/jsref/event_onresize.asp ) states:

onresize is Supported by the Following 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>

 

I can not get a situation where resizing a div causes the oresize handler to be executed.

It looks like onresize only works on the window object and the body tag.

 

Among other things, i tried this, a simple mod to the example code:

<!DOCTYPE html><html><head><script>function myFunction(){var w=window.outerWidth;var h=window.outerHeight;var txt="Window size: width=" + w + ", height=" + h;document.getElementById("demo").innerHTML=txt;}</script></head><body><div style="width:100%" onresize="myFunction()" ><p>Try to resize the browser window.</p><p id="demo"> </p><p>Note: this example will not work properly in IE8 and earlier. IE8 and earlier do not support the outerWidth/outerHeight propery of the window object.</p></div</body></html>

I would like to see a working example where the onresize event handler as attribute of a div tag is actually executed, or, if it is indeed not possible, to get the documentation updated according to the actual possibilities.

Link to post
Share on other sites

This seems to be an error in the documentation. According to MDN, on the window object supports the onresize event.

http://mdn.beonex.com/en/DOM/element.onresize.html

http://stackoverflow.com/questions/19329530/onresize-for-div-elements

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...