JQuery noConflict not working only in IE8

I have a site using the prootype structure and I am looking to use a jquery plugin. Everything does not work in IE8. It works in ie7, which amazes me. Any idea what could be wrong?

IE8 gives me an object that does not support this property or method, where the line is jQuery.noConflict (); this is

<script src="/my/docs/jquery.js" type="text/javascript"></script> <script src="/my/docs/jquery.simplyscroll.js" type="text/javascript"> </script> <script type="text/javascript"> jQuery.noConflict(); function OpenUp(sURL){ window.open(sURL,null,'height=560,width=820,status=yes,toolbar=yes,menubar=yes,location=yes,resizable=yes,scrollbars=yes',false); } jQuery(document).ready(function($) { $("head").append("<link>"); css = $("head").children(":last"); css.attr({ rel: "stylesheet", type: "text/css", href: "/my/docs/jquery.simplyscroll.css" }); $("#scroller").simplyScroll({ autoMode: 'loop', framerate: 1, speed: 1 }); }); </script> 

I am also tired of the following: var $j = jQuery.noConflict(); var j = jQuery.noConflict(); var $j = jQuery.noConflict(); var j = jQuery.noConflict();

everythig works not only in IE8.

+7
javascript jquery internet-explorer-8
source share
8 answers

I came across this also with jQuery-1.4.4.js. Everything works fine except for IE8. IE8 doesn't recognize jQuery () anything. I was able to solve the problem by loading jQuery and running $ .noconflict () before downloading Prototype, and all this works fine in all my test browsers, including IE8. This sequence is contrary to jQuery documentation, and so I'm nervous about this. Cannot find anything on jQuery site.

t22harris

+6
source share

The only way I was able to fix this for IE8 (which was the only one with the problem) and other browsers was to put the jQuery and noConflict () call in the head immediately after initializing another library. For example:

<script type="text/javascript" src="/path/to/prototype.js"></script>

<script type="text/javascript" src="/path/to/jquery.js"></script>

<script type="text/javascript">var $j = jQuery.noConflict(); </script>

... then any other scripts that use either jQuery or Prototype follow.

+2
source share

I had a similar problem. The solution I'm currently using is to save the $ variable in a temporary variable by loading jquery (I load jquery from js code), run jquery-dependent code (with jQuery.noConflict), setting the $ variable back.

It's dirty, but it seems like a trick for me.

My function, which adds jquery (if necessary):

 function getJQueryAndGo(callback) { var thisPageUsingOtherJSLibrary = false; var tempDollar = $; // Only do anything if jQuery isn't defined if (typeof jQuery == 'undefined') { if (typeof $ == 'function') { thisPageUsingOtherJSLibrary = true; } loadToHead('script','http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js', function() { if (typeof jQuery=='undefined') { //alert('Super failsafe - still somehow failed...') } else { jQuery.noConflict(); (function($) { callback($); })(jQuery); } }); } else { // jQuery was already loaded jQuery.noConflict(); // This may not be necessary (function($) { callback($); })(jQuery); } $ = tempDollar; } 

LoadToHead just loads the script into the header tag somewhere and runs the callback function when the script loads.

I found most of this code on the Internet and tweeked it. Unfortunately, I do not remember where to give a loan at the moment.

+2
source share

In the past I had a simulated problem and it worked around it using the ie7 emulation meta tag

 <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> 

I'm not sure this is the best job.

+1
source share

Just the same problem. IE 8 does not like:

 var jQuery = jQuery.noConflict(); 

changed it to:

 var jq = jQuery.noConflict(); 

worked fine.

+1
source share

I had strange problems in the past with IE8 on machines with multiple versions of IE. In my case, an error appeared when I tried to open the link in a new window through javascript. The same code worked fine on IE6 and 7, and a machine with only IE8 installed also worked fine.

0
source share

This is a problem that I also discovered. I fixed this to upgrade jQuery to 1.4. Version 1.3.2 crashes with the new IE8 prototype. Sorry, this response is being delayed.

0
source share

I have the same error with 1.4.4 and 1.4.3 loading jquery after the prototype and only in IE8, even in Ie7 or Ie6 JQuery 1.4 solved this for me.

0
source share

All Articles