Invalid IE caller

In FF and Chrome, I can set this value for a location object using bind, with the following code

locationFacade ={ reload: location.reload.bind(location) } locationFacade.reload(); 

Or I can use apply

 locationFacade ={ reload: function(){ location.reload.apply(location,arguments); } } locationFacade.reload(); 

However, in IE 9, I keep getting "Invalid caller" when calling locationFacade.reload (); I have not tested every IE, but the problem also occurs in IE 11. Apply and bind are supported in IE here and here.

+6
source share
1 answer

This problem seems to be an IE bug. I tested many functions in IE11 (document.writeln, window.alert, etc.), and all of them could be connected, except for location members. This workaround may help:

 locationFacade = { reload: window.navigate ? window.navigate.bind(window, location.href) : location.reload.bind(location) } 
+3
source

Source: https://habr.com/ru/post/975434/


All Articles