是否可以检查多少字节的HTML页面得到加载? [英] Is it possible to check how much bytes get loaded in HTML Page??

查看:141
本文介绍了是否可以检查多少字节的HTML页面得到加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

时可以检查多少字节 HTML页获取加载?如果没有,任何人都可以解释如何做这些个preloader 工作在HTML页面或他们只是假象,为用户??

Is it possible to check how much bytes get loaded in HTML Page?? If not, Can anyone explains how does these percentage preloader works in html pages or they are just illusion for users??

我要创建 pre-装载机我的网站具有类似的功能闪光灯pre-装载机。但不知道如何查询网站中的每个元素是否会被加载或仍在加载。

I want to create pre-loader for my website having functionality similar to flash pre-loaders. But can't understand how to check whether each element of website gets loaded or still loading.

推荐答案

它返回的HTML页面的大小以字节为单位或者你可以得到Content-Length头

It returns the size of the html page in bytes Or you can get the content-length header

var request = new XMLHttpRequest();
request.open('GET', document.location, false);
request.send();
var size = request.getAllResponseHeaders().toLowerCase().match(/content-length: \d+/);
document.getElementById("size").innerHTML = size + " bytes";

这篇关于是否可以检查多少字节的HTML页面得到加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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