简体   繁体   English

SCRIPT5:由于Wordpress中的jQuery.min CDN文件,IE9上的访问被拒绝

[英]SCRIPT5: Access Denied on IE9 due to jQuery.min CDN file in Wordpress

I've read quite a few other articles on the SCRIPT5: Access is Denied issue in IE9 but as far as I can tell this one is a little different and I'm not exactly sure why its happening. 我在SCRIPT5上阅读了很多其他文章:在IE9中访问被拒绝的问题,但据我所知,这个有点不同,我不确定为什么会发生这种情况。

The situation arose on a Wordpress 3.4.1 install using the standard 2011 theme. 在使用标准2011主题的Wordpress 3.4.1安装中出现了这种情况。 I enqueued my scripts with the following function: 我使用以下函数将我的脚本排入队列:

function my_scripts(){
    wp_deregister_script('jquery');
    wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js',null,null,true);
    wp_register_script('cycle', 'http://ajax.microsoft.com/ajax/jquery.cycle/2.88/jquery.cycle.all.js',null,null,true);
    wp_register_script('plugin', get_stylesheet_directory_uri() . '/scripts/plugin-init.js',null,null,true);
    wp_enqueue_script('jquery');
    wp_enqueue_script('cycle');
    wp_enqueue_script('plugin');
}

First the jquery and the cycle scripts are both being pulled from CDNs. 首先, jquerycycle脚本都是从CDN中提取的。 The plugin script is empty with the exception of a basic cycle call on a single element. plugin脚本为空,但单个元素上的基本cycle调用除外。

At this point all browsers worked fine with the exception of IE9. 此时所有浏览器都可以正常工作,但IE9除外。 I received the following error: 我收到以下错误:

 SCRIPT5: Access is denied
 jquery.min.js, line 2 character 68522 

I found out quickly enough that this was a cross origin issue: 我很快发现这是一个交叉问题:

Access denied to jQuery script on IE 在IE上拒绝访问jQuery脚本

SCRIPT5: Access is denied in IE9 on xmlhttprequest SCRIPT5:在xmlhttprequest上的IE9中拒绝访问

I found this odd since there were no cross origin functions in my plugins. 我发现这很奇怪,因为我的插件中没有交叉原点功能。 Also the issue was showing up on jquery itself and not my code. 此问题也出现在jquery本身而不是我的代码上。 Tried several suggested fixes but had no luck. 尝试了几个建议的修复,但没有运气。

Tried some basic stuff. 尝试了一些基本的东西。 Moved the script directly into the footer. 将脚本直接移动到页脚。 Tried moving it directly into the header. 尝试将其直接移动到标题中。 Tried cutting my scripts out of the equation. 尝试将我的脚本排除在外。 Pulling my hair out at this point. 此时拔掉我的头发。

My best bet was going to be to actually see what was causing the error in the code (since I couldn't on the minified version). 我最好的选择是实际看到导致代码错误的原因(因为我无法在缩小版本上)。 At this point the code was directly in the header so removed the .min from the script, did a refresh, and TA-DA: Everything is now working without a hitch. 此时代码直接在头文件中,因此从脚本中删除了.min ,进行了刷新,并且TA-DA:现在一切都正常运行。

If I try to move the unminified script declaration back to the my_scripts() function using wp_register_script & wp_enqueue_script it will fail again. 如果我尝试使用wp_register_scriptwp_enqueue_script将未分解的脚本声明移回my_scripts()函数,它将再次失败。 If I try to move the unminified script declaration into the footer it will fail again. 如果我尝试将未经通知的脚本声明移动到页脚中,它将再次失败。 I did not test a local copy at the time, only the CDN versions. 我当时没有测试本地副本,只测试了CDN版本。

It's the same SCRIPT5 error but I unfortunately don't have the code the error is generating from handy. 这是相同的SCRIPT5错误,但遗憾的是我没有错误产生的代码。 This was at the office the other day and I'm off for the weekend. 前几天这是在办公室,我周末休息。 I attempted to reproduce the events on my personal sandbox but was unsuccessful in recreating the error, which leads me to believe something unlisted may be the culprit. 我试图在我的个人沙箱上重现这些事件,但是在重新创建错误方面没有成功,这让我相信一些未列出的内容可能是罪魁祸首。

Does anyone have any idea what's going on here? 有谁知道这里发生了什么? Why would jquery.min fail where the unminified file would not? 为什么jquery.min会在未通知文件的情况下失败? And why would the unminified file continue to fail unless its directly in the <head> ? 为什么未通报的文件会继续失败,除非它直接在<head>

Happy to supply more information, although some of it may have to wait until I return to work this coming week. 很高兴提供更多信息,虽然有些信息可能要等到我下周回到工作岗位。 As soon as I'm able I will try to get the rest of the code posted. 一旦我能够,我将尝试发布其余的代码。

我有同样的问题,jQuery 1.8.1为我解决了这个问题

For some reason, @axel's answer didn't work for me. 出于某种原因,@ axel的答案对我不起作用。 Instead I decided to host the file on the same server as my HTML files and it fixed it (for me at least) 相反,我决定将文件托管在与我的HTML文件相同的服务器上并修复它(至少对我来说)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM