如何使用javascript获取网页的长度/大小 [英] how to get length/size of a webpage using javascript

查看:98
本文介绍了如何使用javascript获取网页的长度/大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用w3c导航API获取网页计时信息.
我们使用资源计时API获取资源信息.
现在,如何获取网页的大小.看来,如果我知道页面何时加载等,我应该知道何时下载了最后一个字节-这应该足以给我页面的长度/大小.

We get the webpage timing info using w3c navigation API.
we get the resource information using the resource timing API.
Now, how to get the size of the webpage. It appears that if I know when the page loaded, etc, I should know when the last byte was downloaded -- this should be enough to give me the length/size of the page.

如何获得此长度/尺寸?

How do I get this length/size ?

推荐答案

在以下位置找到了答案:

Found the answer at : How to get current page size in KB using just javascript?. User @Stev has answered it

document.getElementsByTagName('HTML')[0].outerHTML.length;

这篇关于如何使用javascript获取网页的长度/大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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