Why does $(window).load() work but not $(document).ready()?

末鹿安然 提交于 2019-12-04 08:09:55

There is a conflict with the body's onready= callback registered. See the jquery docs. You must remove the <body onload="initialize()">.

http://api.jquery.com/ready/

Also a possibility is a resource being loaded very VERY slowly. However the first is more likely.

.ready is triggered when resources are loaded. It is possible a resource may be perpetually in a wait state because the server never closed the socket when sending the resource to the browser. Use firebug's network monitor tool to track down if this is the case.

What about a workaround... Did you know that a SCRIPT tag at the end of the BODY tag, is executed when everything before is loaded in the DOM ?

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