Rob,

Point taken about using onLoad for a script tag possibly not being
supported. In this case however that part of the code is working fine.
The issue I am having is related to jQuery being added to a page after
the page has completed loading. When this happens ready listeners are
never executed. If jQuery is present when the page loads then ready
listeners are executed as expected.

Ryan

On Oct 8, 12:45 am, RobG <robg...@gmail.com> wrote:
> On Oct 8, 10:04 am, Ryan Crumley <crum...@gmail.com> wrote:
>
> > I am experiencing unexpected behavior using $(document).ready() on a
> > page where I inject jQuery after the page has loaded and then attach
> > listeners to the ready event. The ready() event is never called using
> > Firefox and Safari however it is called using IE.
> [...]
> >                 function loadjquery() {
> >                         var url = 
> > "http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/
> > jquery.js";
> >                         var head = 
> > document.getElementsByTagName("head")[0], done = false;
> >                         var script = document.createElement("script");
> >                         script.src = url;
>
> >                         script.onload = script.onreadystatechange = 
> > function() {
>
> There is no onload attribute for script elements defined in HTML 4.01,
> therefore you should not expect that a script element will fire a load
> event. The fact that some browsers do and some don't should be enough
> to tell you that browser behaviour is inconsistent.  You are unlikely
> to be able to reliably fix that with script.
>
> If you want a reliable indicator that a script has finished loading
> and is ready for use, put a statement at the bottom like:
>
>   var SCRIPT_LOADED = true;
>
> --
> Rob

Reply via email to