3

I know I can let one element resize through css3 resize property:

resize: both;
overflow: auto

but can I catch the resize event? like:

element.addEventListener('resize', fn, false);

I try this, but it doesn't work, is there other way to do this kind of job?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
hh54188
  • 14,887
  • 32
  • 113
  • 184

2 Answers2

1

As per this answer, you may try:

var addEvent = function(elem, type, eventHandle) {
    if (elem == null || elem == undefined) return;
    if ( elem.addEventListener ) {
        elem.addEventListener( type, eventHandle, false );
    } else if ( elem.attachEvent ) {
        elem.attachEvent( "on" + type, eventHandle );
    } else {
        elem["on"+type]=eventHandle;
    }
};

Called:

addEvent(element, 'resize', fn);    // you may want to try 'onresize'
Community
  • 1
  • 1
vol7ron
  • 40,809
  • 21
  • 119
  • 172
0

you can use Jquery .resize( handler(eventObject) ) executed on window resize:

 $(window).resize(function() {
     $('#log').append('<div>Handler for .resize() called.</div>');
 });
juhan_h
  • 3,965
  • 4
  • 29
  • 35