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