Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

The situation arose on a Wordpress 3.4.1 install using the standard 2011 theme. 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. The plugin script is empty with the exception of a basic cycle call on a single element.

At this point all browsers worked fine with the exception of 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

SCRIPT5: Access is denied in IE9 on xmlhttprequest

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. 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.

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. 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.

It's the same SCRIPT5 error but I unfortunately don't have the code the error is generating from handy. 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? And why would the unminified file continue to fail unless its directly in the <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.

like image 678
voodooGQ Avatar asked Sep 02 '12 00:09

voodooGQ


1 Answers

i had the same problem, jQuery 1.8.1 fixed this problem for me

like image 91
axel Avatar answered Sep 21 '22 05:09

axel