I have some serious problem with getting asynchronously some js libs and executing them in $(window).load
in IE
all works in other browsers of course
so the problem is, that I'm doing something like
<script type="text/javascript">
var scr1 = document.createElement('script');
scr1.type = 'text/javascript';
scr1.src = 'some_lib.js';
$('BODY').prepend(scr1);
</script>
Just before </body>
and use $(window).load
method in html above it to operate on some plugins in some_lib.js
, but it all happens to fast in IE, probable because of that asynchronous lib including, and I get an error, that method is not available for the element.
Is there any chance of maybe modyfying $(window).load
method so I still could use it in the same way for every browser ?
Any code that you have in the
window.load()
call must be placed in a function (calledonLoad
in this example).Every time you have a script that you dynamically load, increment a counter. Also include something to decrement that counter...
Then in 'onLoad' have the first line...
That means that
onLoad
will fire atwindow.load
and after every script is loaded, but will only execute when it's all loaded.It's scrappy, but it will solve your problem.