获取使用JavaScript的网页加载百分比? [英] Get the percentage of the page load using javascript?

查看:68
本文介绍了获取使用JavaScript的网页加载百分比?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个iphone应用程序,需要显示一个进度条来显示网页的加载进度.我想在此页面上插入一个JS函数,一旦调用它,它将给我加载进度(已加载多少字节以及总大小).这可能吗?

I'm writing an iphone application and need to show a progress bar that shows the loading progress of a web page. I want to insert a JS function to this page and once I call it, it will give me the load progress (how much bytes have been loaded and the total size). Is this possible?

谢谢

推荐答案

否,这是不可能的.您可以通过将页面分解成小块并通过ajax请求将其逐个加载来模拟它,但我认为这样做不值得.

No, it's not possible. You can emulate it by breaking up your page to small pieces and load it one by one with ajax requests but I don't think it is worth the trouble.

另一个想法是放一些像这样的小脚本

Another idea is to put little pieces of script like

<script>percentage += 10; updateProgressBar();</script>

通过您的页面.该脚本将在第二个浏览器加载(或解析)该脚本时执行,以便您可以估算进度.

through your page. That script will be executed the second browser loads (or parses) it so you will be able to estimate the progress.

这篇关于获取使用JavaScript的网页加载百分比?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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