Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript window.addEventListener load vs jquery

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #205407
    fooman
    Participant

    When using a script on Firefox, something was not working. Turns out, things were not being loaded across browsers the same. Particularly an SVG was not loaded at the same point in Chrome and FF.

    So eventually I came to use the following:

    window.addEventListener("load", function(){
        setSettings();
    }, false);
    

    Rather than:

    $(function(){
        setSettings();
    });
    

    Any idea why this would not work the same…? Do both of these not fire once the document is loaded? Actually… wouldn’t the Jquery fire after the document is loaded, rather than the window?

    I have a feeling I’m gonna learn me something here ;)

    #205415
    fooman
    Participant

    Thank you!

    #205417
    Shikkediel
    Participant

    Using .load like that is deprecated though, the preferred way would be $(window).on('load', ... ) now.

    https://api.jquery.com/load-event/

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.