IE9 js load order and JQuery

会有一股神秘感。 提交于 2019-12-05 20:35:08
Tom N

I had a similar problem. I fixed it by resetting all my IE9 settings.
I think by cranking up security or privacy it can break jquery loading from an external page.

As far as I could find out, IE9 only fires $.load() when the whole document (including all images & related stuff) has been loaded. Terrible but true! My workaround for this:

            var docReady = {
                actions:new Array(),
                flag:0,
                time:0,
                period:10,
                trigger:function() {this.flag=1},
                checkHandle:0,
                check:function() {
                    this.time+=this.period;
                    if(this.flag) {
                        clearInterval(this.checkHandle);
                        for(i in this.actions) {this.actions[i]();}
                    }
                },
                watch:function() {
                    this.checkHandle = setInterval(function() {docReady.check();},this.period);
                },
                action:function(f) {
                    this.actions.push(f);
                }

            };

            docReady.watch();

A dirty one indeed but it's working; now whenever you see fit, you can call docReady.trigger() and you should do it at least at the end of the page. Also, you can call it as body onload. It's guaranteed that the functions you've added with docReady.action() will only run once: when the first trigger() happens.

Have you tried to leave out defer="defer"?

James

I had the same problem and solved it by NOT using Google's hosted jQuery and hosting it locally.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!