简体   繁体   中英

Loading a page after progress bar loads

I have a progress bar that loads from a width of 1 to 100 percent with javascript. 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. Here is my javascript for that.

 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

 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"; } } } }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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