Javascript:window.onload问题

Mat*_*rym 1 javascript internet-explorer window onload

这在IE中不起作用(尽管它在FFX中有效).为什么?

在标题中使用HTML:

<script type="application/javascript">

    // And finally, let's call the code ourselves.
    window.onload = lbp.init;

</script>
Run Code Online (Sandbox Code Playgroud)

然后脚本:

// lbp is the script's universal variable, which retains everything
var lbp = {};

// The sequence of functions to trigger
lbp.init = function() {
    alert('hi');
}
Run Code Online (Sandbox Code Playgroud)

在此先感谢您的帮助=)

RoT*_*oRa 6

我不知道IE是否支持application/javascript.你试过text/javascript吗?

另外:lbp在设置之前初始化window.onload