SCRIPT438 Error in Internet Explorer 11

前端 未结 4 2109
野的像风
野的像风 2020-12-28 18:06

I\'ve been working on JavaScript lately, and everything was fine until I opened my page in IE11. as per Mozilla website .forEach is supported f

4条回答
  •  粉色の甜心
    2020-12-28 18:36

    I was doing so:

    Array.from(document.querySelectorAll(someElements))
    

    The asnwer for me was simply that:

    if (window.NodeList && !NodeList.prototype.forEach) {
       NodeList.prototype.forEach = Array.prototype.forEach;
    }
    

    Making sure that forEach also exists in Nodelist.

提交回复
热议问题