如何检测,谷歌即时页面已完全加载? [英] How to detect that Google Instant page has loaded completely?
问题描述
我工作的一个浏览器插件(想想 SEOQuake ) - 我需要显示在搜索结果的一些数据显示
I'm working on a browser extension (think SEOQuake) - I need to display some data about the search results that are shown.
问题:如果有什么事情被添加到谷歌即时搜索结果页,同时它还是在被加载的过程中,它会覆盖任何补充。我抓住了自己写一些非常靠不住的setInterval业务(等待,直到 OL#的内容RSO
停止大小发生变化,类似的东西),所以我想这意味着我不知道如何可靠地确定页面加载完成。
Issue: If anything is added to the Google Instant results page while it's still in the process of being loaded, it'll overwrite any additions. I caught myself writing some really wonky setInterval business (waiting until the contents of ol#rso
stop changing in size, stuff like that) so I suppose that means I'm not sure how to reliably determine if the page is done loading.
我的可以的只是它等待1-2秒,但我真的要开始获取数据,一旦结果被加载,以节省时间最高金额。
I could just have it wait 1-2 seconds but I really want to start fetching the data as soon as the results are loaded to save maximum amount of time.
编辑:请记住,我不能使用DOMElementWhatever因为IE8不支持它
Keep in mind, I can't use DOMElementWhatever because IE8 doesn't support it.
推荐答案
试试这个:
window.addEventListener("message", function(e) {if(e.data == 'jrc') console.log('loaded')}, false);
这应该工作在IE 8+和所有其他浏览器: http://caniuse.com /#壮举= X-DOC-消息
That should work in IE 8+ and all other browsers: http://caniuse.com/#feat=x-doc-messaging
如果没有在IE 8的工作(不能在我的Mac测试在现在),让我知道。我相信,我在最后一小时的rs.js一些相当不错的理解。 ;)
If that doesn't work in IE 8 (can't test in on my Mac right now), let me know. I believe I got some reasonably good understanding of the rs.js in the last hour. ;)
这篇关于如何检测,谷歌即时页面已完全加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!