开发者

MooTools: Window load

I have a page and use window.addEvent('load', function() { alert('test'); }), but the browser never displays the alert. There are no JavaScript errors on the page that prevent this from running.

What might be happening? Is it possible that the page already loaded so the 'load' even doesn't fir开发者_如何学编程e?


You might want to try using the 'domready' event. Once the DOM is loaded in the window, the function would be executed.

window.addEvent('domready', function(evt) {
   alert('dom loaded!');
});


You must have an error or something. Look: http://mootools.net/shell/vcBsn/

Also, if possible post a link to your test-case.


Check in firebug if all ur scripts are getting loaded (due to path error script might not be getting loaded) Also include the mootools scripts first then ur custom scripts.


In IE7, the following code will not do if the html page has little content

window.addEvent("domready", function() {
    $(window).addEvents( {
        "load" : loadListener
    });
    function loadListener() {
        window.alert("Window has loaded!");
    }
});

And these code shoud be changed like this:

window.addEvents( {
    "load" : function() {
        window.alert("Window has loaded!");
    },
    "domready" : function() {
        /* do something */
    }
});

Is it the solution for you problem?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜