简体   繁体   English

Javascript,在网站加载之前加载进度条

[英]Javascript , loading progress bar before site loads

I want to make a progress bar for a GUI site that I am making and I need a bit of code in javascript to detect if the site is loading and how many elements/images have loaded and has the site fully loaded. 我想为我正在制作的GUI网站制作一个进度条,我需要在javascript中使用一些代码来检测网站是否正在加载以及已加载了多少元素/图像并且网站已满载。 I have the progress bar made with css and I dont know how I can turn on/of elements in js. 我有用css制作的进度条,我不知道如何打开js中的元素。

How can I accomplish this in js or by using Jquery ? 如何在js中或使用Jquery完成此操作?

Some solutions to achieve what you want are: 实现您想要的一些解决方案是:

  • Code a really little page with nothing but your favourite js framework (jQuery maybe?) and a little code that requests the rest of the elements of the page dinamically with AJAX counting which ones are finished or not with the load events. 编写一个真正的小页面,只有你最喜欢的js框架(可能是jQuery?)和一些代码,它通过AJAX计算页面的其余元素,并计算哪些是否已完成加载事件。
  • For images you can also link "load" event and do a progress bar counting the total images grated/images loaded. 对于图像,您还可以链接“加载”事件并执行进度条计算已磨碎的图像/加载的图像。
  • Other combiantions of the other two. 其他两个的其他组合。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM