gpt4 book ai didi

javascript - 权限被拒绝调用 javascript 函数

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:43:56 25 4
gpt4 key购买 nike

我正在尝试制作 ie7-js使用我的 wordpress 安装。在阅读了这个库之后,它似乎是一个很好的解决方案,可以让我的网站更兼容旧版本的 IE,尤其是 IE8。尝试并仍然支持这样的旧浏览器似乎很奇怪,但我注意到每个月有数百名访问者使用与 IE6 一样旧的浏览器访问我们的网站。我们的大多数用户都是老年人,并且仍在使用 Windows XP。现在开始讨论这个问题。

我正在使用来自 modern.ie 的 IE8 运行 Windows XP 虚拟机的副本我已按照库代码页上有关如何包含该文件的说明进行操作。我正在尝试让特定的 IE9.js 文件正常工作。当我在 IE8 中访问该页面时出现错误

permission denied: line 850 character 37

我已经追踪到下面一行:

for (var i = 0, imported; i < styleSheet.imports.length; i++)

来自这个函数:

function getCSSText(styleSheet, path, media, level) {
var cssText = "";
if (!level) {
media = toSimpleMedia(styleSheet.media);
level = 0;
}
if (media === "none") {
styleSheet.disabled = true;
return "";
}
if (media === "all" || media === self.media) {
// IE only allows importing style sheets three levels deep.
// it will crash if you try to access a level below this
try {
var canAcess = !!styleSheet.cssText;
} catch (exe) {}
if (level < 3 && canAcess) {
var hrefs = styleSheet.cssText.match(IMPORTS);
// loop through imported style sheets
for (var i = 0, imported; i < styleSheet.imports.length; i++) {
var imported = styleSheet.imports[i];
var href = styleSheet._href || styleSheet.href;
imported._href = hrefs[i].replace(TRIM_IMPORTS, "");
// call this function recursively to get all imported style sheets
cssText += getCSSText(imported, getPath(href, path), media, level + 1);
}
}
// retrieve inline style or load an external style sheet
cssText += encode(styleSheet.href ? loadStyleSheet(styleSheet, path) : styleSheet.owningElement._cssText);
cssText = parseMedia(cssText, self.media);
}
return cssText;
};

在研究是否有其他人遇到过同样的问题后,我确实找到了 posts关于它,但没有人有解决方案。几个小时以来,我一直在努力解决这个问题,结果我的头撞到了 table 上。有没有人有可能的解决方案或接下来要检查的事情?我已尝试将文件权限更改为 777,但这似乎也不起作用。

最佳答案

旧版浏览器在客户端使用 CORS 时存在限制。

不完全是他的 javascript 中的“错误”,无法由客户端纠正。

最好的方法是使用 CDNs有权访问 CORS .

但这仍然很困难,所以另一种选择是将所有 CSS 放在您(或您自己的域)的子域中。

了解 CORS:

关于javascript - 权限被拒绝调用 javascript 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25247499/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com