对象不支持 属性 或方法 'querySelectorAll' (sp.core.debug.js)

Object doesn't support property or method 'querySelectorAll' (sp.core.debug.js)

首先我想告诉我我是 SharePoint 的新手。我在 SharePoint 2013 中开发了一个 public 网站。当我在 IE 7 中打开我的网站时,sp.core.debug.js

中出现以下异常
Object doesn't support property or method 'querySelectorAll'
Object doesn't support property or method 'querySelector'

和sp.core.debug.js是一个框架文件,位于_layouts/15/ 任何解决方案如何解决此问题。提前致谢。

编辑:

 {(function () {
    if (document.querySelectorAll || document.querySelector) {
        return;
    }
    var
        style = document.createStyleSheet(),
        select = function (selector, maxCount) {
            var
                all = document.all,
                l = all.length,
                i,
                resultSet = [];

            style.addRule(selector, "*[id*='ElementId']");
            for (i = 0; i < l; i += 1) {
                if (all[i].id === "ElementId") {
                    resultSet.push(all[i]);
                    if (resultSet.length > maxCount) {
                        break;
                    }
                }
            }
            style.removeRule(0);
            return resultSet;
        };

    document.querySelectorAll = function (selector) {
        return select(selector, Infinity);
    };
    document.querySelector = function (selector) {
        return select(selector, 1)[0] || null;
    };
}());}

上面的代码工作正常,但它没有调用对象 disphtmldivelement,如何在对象 disphtmldivelement 上调用 QuerySelector 和 QuerySelectorAll 方法。

IE 7 根本不受 Sharepoint 代码的支持。

参见:Plan browser support in SharePoint 2013

您可以使用 IE7 querySelector polyfill and IE7 querySelectorAll polyfill 来支持 IE 7。

IE7不支持querySelectorAll。它未定义,因此您必须检查它并在 javascript 代码中自行定义它。你可以这样做。

{(function () {
    if (document.querySelectorAll || document.querySelector) {
        return;
    }
    var
        style = document.createStyleSheet(),
        select = function (selector, maxCount) {
            var
                all = document.all,
                l = all.length,
                i,
                resultSet = [];

            style.addRule(selector, "*[id*='ElementId']");
            for (i = 0; i < l; i += 1) {
                if (all[i].id === "ElementId") {
                    resultSet.push(all[i]);
                    if (resultSet.length > maxCount) {
                        break;
                    }
                }
            }
            style.removeRule(0);
            return resultSet;
        };

    document.querySelectorAll = function (selector) {
        return select(selector, Infinity);
    };
    document.querySelector = function (selector) {
        return select(selector, 1)[0] || null;
    };
}());}