views:

34

answers:

2

Hi,

My site is runnin fine on mac ff/safari. On pc ie 7/8 and chrome I get an error $ is not defined relating to

$(window).load(function (){}

Can anyone suggest a workaround. I chose to use window.(load) over (document).ready as I am loading in some big background images and would like them to load at the start rather than risk loading delays later.

Thanks!

A: 

Make sure that you have included the jQuery libaray into your page.

Sarfraz
A: 
  • make sure jQuery is loaded on your page

    if(typeof jQuery === 'undefined'){
        alert('no jQuery :(');
    }
    
  • make sure the $ is available and assigned correctly

    (function($){
        $(document).ready(function(){
        });
    })(jQuery);
    
jAndy
`jQuery(document).ready(function($) { });` ;) or just `jQuery(function($) { });` No need for an extra closure :)
Nick Craver
@Nick: well, maybe OP don't want directly call `.ready()`. What about `$.fn.plugin = ...` for instance, using `$`.
jAndy
@jAndy - The plugin would be in the page...why? :) Plugins should themselves **never** rely on `$`, but all of this is beside the point, we know exactly what he's trying to call, `$(window).load()`. That wouldn't work in any browser if he had a problem with `$` like this, it's more likely he has malformed `<script>` tags.
Nick Craver
Hi,Thanks for your quick responses.Seems the pc I'm working on dropped internet connection. I now using local version and $(window).load is working/ Although now ie reports invalid argument in the jquery-1.4.2.min.js line:144 Char:219 Thanks Again (oh and the OP is a she ;))?!
Melzee
@user386312: that error seems to have another origin if `$(window).load()` is working now, should maybe another post or edit it here.
jAndy