简体   繁体   English

进度条加载后加载页面

[英]Loading a page after progress bar loads

I have a progress bar that loads from a width of 1 to 100 percent with javascript.我有一个进度条,使用 javascript 从 1% 到 100% 的宽度加载。 Just wanted to find out if there is a way to mess with the javascript to make it load a page after it reaches a width of one hundred percent.只是想知道是否有办法弄乱 javascript 以使其在达到 100% 的宽度后加载页面。 Here is my javascript for that.这是我的 javascript。

 var i = 0; function move() { if (i == 0) { i = 1; var elem = document.getElementById("mybar"); var width = 1; var id = setInterval(frame, 10); function frame() { if (width >= 100) { clearInterval(id); i = 0; } else { width++; elem.style.width = width + "%"; elem.style.delay = "3s"; } } } }

Set the window.location.href property inside the "if (width >= 100)" part在 "if (width >= 100)" 部分设置 window.location.href 属性

 var i = 0; function move() { if (i == 0) { i = 1; var elem = document.getElementById("mybar"); var width = 1; var id = setInterval(frame, 10); function frame() { if (width >= 100) { clearInterval(id); i = 0; setTimeout(function () {window.location.href = 'http://www.google.com'}, 3000); } else { width++; elem.style.width = width + "%"; elem.style.delay = "3s"; } } } }

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

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