views:

85

answers:

2
    <head>
    <meta name="description" content="Directory" />
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt; </script>

 <script type="text/javascript" src="https://sitename.com/javascripts/toggle.js" language="javascript"></script>

    </head>

this is the error showing in IE 7. I haven't checked in IE8 and 6.

Message: 'jQuery' is undefined
Line: 1
Char: 1
Code: 0
URI: https://sitename.com/javascripts/toogle.js

This is code of external javascript

(function($) {

     $(document).ready(function(){
          $('.divhide').hide();
                  $('#ShowFields').show();
$('.DirectoryLink') .addClass('plus');
$('#DirectoryLink') .addClass('minus');
        $('.DirectoryTextLink').click(function(){
              $(this).next().slideToggle();
        $(this).toggleClass('minus');
                return false;
   });
});


})(jQuery);
+3  A: 

Did you include the jQuery file before toogle.js?

EDIT 1: Also: Get rid of the language attribute in your script tag. Not sure if it will fix it, but it's deprecated anyways so you don't need it:

<script type="text/javascript" src="https://sitename.com/javascripts/toggle.js" language="javascript"></script>

Instead use:

<script type="text/javascript" src="https://sitename.com/javascripts/toggle.js"&gt;&lt;/script&gt;

EDIT 2: In toogle.js add this line before the self invoking function:

jQuery.noConflict();

Even though you're reassigning $ in the function, you may still need to call the noConflict method.

From: http://api.jquery.com/jQuery.noConflict/

CD Sanchez
@Daniel - yes. it's working fine in firefox
metal-gear-solid
@Daniel, does it effect our script if we include 'language' attribute in script tag ?
Ninja Dude
@Samurai Jack: I doubt it, but it's typically considered bad practice to use deprecated attributes or elements. Although most deprecated features still work, it doesn't mean it will always work.@metal-gear-solid: See my new edit.
CD Sanchez
@Daniel Thank you !
Ninja Dude
A: 

This is happening because one script is http and the other is https, this will cause a security issue with IE when the parent page is on a https. If your parent page is on a https you must have everything on https, including images and scripts.

Rodrigo
but it's working fine in Firefox
metal-gear-solid
@metal-gear-solid: Try it anyways. Internet Explorer has a lot of "security features" that will randomly break stuff.
CD Sanchez
firefox is more permissive when it comes to https, ie will just ignore everything that's not https and depending on the security configuration it will not even ask
Rodrigo