从Javascript读取当前文档的大小 [英] Read size of current document from Javascript

查看:149
本文介绍了从Javascript读取当前文档的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始玩 Boomerang 来衡量表现。这是非常有希望的。虽然它允许我测量延迟,带宽和页面加载时间,我也有兴趣想要花费时间来渲染初始的HTML页面服务器端。记录浏览器开始解析javascript(当它最初到达时接近的时间)的时间似乎很简单,为了得到服务器时间的估计,我需要弄清楚要扣除的网络时间。所以要做到这一点,我需要知道html文档的大小。

I'm starting to play around with Boomerang for measuring performance. It's very promising. While it allows me to measure latency, bandwidth and page load times, I'm also interested in trying to get the time it took to render the initial HTML page server-side. Wile it seems straightforward to log the time at which the browser started parsing the javascript (which is close to when it initally arrived) in order to get an estimate of the server time, I need to work out how much network time to deduct. So to do that, I need to know how large the html document is.

我如何从Javascript中得知?

How can I tell this from Javascript?

文档对象似乎没有innerHtml属性

The document object does not appear to have an innerHtml property

我尝试

totsize=document.HEAD.innerHTML.length + document.BODY.innerHTML.length;

HEAD和BODY实体出现在Firefox中的DOM浏览器中 - 但是当我尝试上面的代码时得到一个未定义的错误 - 也尝试用'head' - 无效。

The HEAD and BODY entities appear in the DOM browser within Firefox - but when I try the code above I get an undefined error - also tried with 'head' - to no avail.

任何想法?

请注意,javascript是一个单独的文件,并将在大多数情况下缓存 - 这不是一个大问题)。

(note that javascript is in a seperate file and will be cached in most cases - so that's not a big problem).

我尝试过谷歌 - 但我只是得到很多描述html元素的屏幕尺寸和窗口尺寸的页面:(

I did try google - but I just get lots of pages describing the on-screen size of html elements and the window dimensions :(

TIA

推荐答案

document.documentElement.innerHTML.length

这篇关于从Javascript读取当前文档的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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