在window.onload相当于Ajax应用程序? [英] window.onload equivalent for Ajax applications?

查看:119
本文介绍了在window.onload相当于Ajax应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的window.onload打电话给我的JavaScript code,它有页面之后执行满载。从我读这是推荐的方法来调用这些脚本。

I'm using window.onload to call my JavaScript code that has to be executed after the page is fully loaded. From what I read this is the recommended method to call such scripts.

然而,它不为一些 Ajax的网站的,万维网工作.bing.com例如 - 在window.onload的页面完全呈现之前名为

However, it does not work for some Ajax sites, www.bing.com for instance - window.onload is called before the pages is fully rendered.

有什么建议?

推荐答案

简单的回答是,有解决这个问题(现在)。

The short answer is that there's no general way to solve this problem (right now).

一页的定义是pretty的可替代的,当AJAX的用武之地 - 这是pretty的很难说,旨在为初始页面加载的一部分AJAX之间的差别,并可能不是。所以,浏览器上留下自己来决定何时在window.onload()应该被解雇,而且它并不总是最终,你想要的。

The definition of a "page" is pretty fungible when AJAX comes into play - it's pretty hard to tell the difference between AJAX that is intended to be part of the initial page load, and that which might not be. So, browsers are left on their own to determine when window.onload() should be fired, and it doesn't always end up where you want.

幸运的是,大多数人并不需要的一般的解决方案,而是一个具体的问题。如果你关心bing.com,那么你也许可以看看如何bing.com工作和设计code时,该网站达到你找到可以接受的状态来触发。

Luckily, most people don't need a general solution, but rather a specific one. If you care about bing.com, then you can probably look at how bing.com works and design your code to trigger when the site reaches a state that you find acceptable.

这篇关于在window.onload相当于Ajax应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆