6
I wonder if there is an event that captures changes in the size of an HTML element. For example, a div with 5000px height 4800px and the onresize()
javascript does not fire.
Is there an event that captures this?
HTML:
<div id="teste" style="height:1500px; background:#F00"></div>
JS:
// Evento que vai captura a mudança na altura dp documento
window.onresize = function(){
alert('mudança na altura do documento');
}
// Diminui o div para disparar o evento
setTimeout(function(){
document.getElementById('teste').style.height = '300px'
}, 3000);
Note that the document height is changed but the event of resize
does not fire.
Thank you in advance.
How so the
onresize
doesn’t work? You can post what you have tested?– Sergio
So I want to capture the document height change and not the window.... I posted the test code in the question body. Thanks for the help.
– Douglas dos Santos
Douglas actually only the
window
is what generates this eventresize
. To capture changes in elements you have to usesetInterval
and that can delay the performance a lot. So my question is: what do you really want to do, what makes this size change happen? I think you might be trying to solve the problem in the wrong place.– Sergio
http://benalman.com/projects/jquery-resize-plugin/
– OnoSendai