1

I would like to stop some script working on window resize and replacing it by mine.

The problem is I can't get name of function from script mentioned above. So is there some way to remove all of that WITHOUT USING JQUERY ON IE8? (event listeners does not work).

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

2 Answers2

0

Just override it:

window.onresize = function () { 
   // your code
};

Edit:

I suppose the issue is linked to IE version...

Try that :

window.addEventListener("resize", function (e) {
    e.stopPropagation();
    // your code
});

Update

See for IE8 :

window.attachEvent("resize", function (e) {
    e.stopPropagation();
    // your code
});
Alteyss
  • 513
  • 3
  • 17
  • It is weird. Be sure you are overriding it after the unwanted events are set! – Alteyss Jan 16 '17 at 14:18
  • I know, I even tried to insert your code into interval, but it does nothing :( –  Jan 16 '17 at 14:22
  • Copy/paste the code from my answer in the IE8 console please, then resize. – Alteyss Jan 16 '17 at 14:34
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/133322/discussion-between-alteyss-and-arkadiusz). – Alteyss Jan 17 '17 at 08:13
  • addEventListener does not work on ie8, furthermore I shuld know name of exact function I want to turn off, but I don't. Is there possibility to get full list of functions? All the time I have been googling "list of functions window.onresize" I get list of actions like onclick, onresize ect. –  Jan 17 '17 at 08:15
0

Here is the full answer with a support for IE < 9:

https://stackoverflow.com/a/13651455/3774114

window.attachEvent('onresize', function() {
        alert('attachEvent - resize');
    });
}
else if(window.addEventListener) {
    window.addEventListener('resize', function() {
        console.log('addEventListener - resize');
    }, true);
}
else {
    //The browser does not support Javascript event binding
}

Similarly, you can remove events in the same way

if(window.detachEvent) {
    window.detachEvent('onresize', theFunction);
}
else if(window.removeEventListener) {
    window.removeEventListener('resize', theFunction);
}
else {
    //The browser does not support Javascript event binding
}
Community
  • 1
  • 1
eladc
  • 243
  • 2
  • 6
  • the point is I can't get the name of the function I want to remove. –  Jan 17 '17 at 07:55
  • I have found your exact code on mozilla's page and it does not work on ie8 –  Jan 17 '17 at 08:18