Javascript倒计时与Twitter启动进度条
Javascript Countdown with Twitter Bootstrap Progress Bar
我正在使用Twitter引导程序。我需要在30秒后重定向页面。我想使用Twitter引导进度条来指示页面重定向的时间(因此,当进度条为100%时,页面会重定向)。请有人帮我用Javascript和HTML代码来做这件事。
谢谢;)
非常基本的例子:
var bar = document.getElementById('progress'),
time = 0, max = 5,
int = setInterval(function() {
bar.style.width = Math.floor(100 * time++ / max) + '%';
time - 1 == max && clearInterval(int);
}, 1000);
包装在函数中的代码:
function countdown(callback) {
var bar = document.getElementById('progress'),
time = 0, max = 5,
int = setInterval(function() {
bar.style.width = Math.floor(100 * time++ / max) + '%';
if (time - 1 == max) {
clearInterval(int);
// 600ms - width animation time
callback && setTimeout(callback, 600);
}
}, 1000);
}
countdown(function() {
alert('Redirect');
});
body {padding: 50px;}
<link href="//getbootstrap.com/2.3.2/assets/css/bootstrap.css" rel="stylesheet"/>
<div class="progress">
<div class="bar" id="progress"></div>
</div>
相关文章:
- 我的jQuery插件参数没有正确启动,遇到了问题
- chrome扩展:尽管运行了at:documentidle,js脚本还是过早启动
- 从控制器返回后Ajax启动事件激发
- 在Twitter上用ie9中的空白src访问iframe的contentWindow
- Twitter Bootstrap typeahead:使用“this”获取上下文/调用元素
- Meteor上的启动页面
- 如何防止网页加载后自动启动功能
- 通过javascript/html访问twitter共享iframe
- 如何从JavaScriptInterface启动Navigation Drawer
- window.on.scroll事件未启动
- 使用Javascript获取Twitter访问令牌
- Twitter引导程序Typeahead-Id&标签
- 单击按钮后启动javascript提示
- 仅在加载活动类图像时启动功能 - Twitter 引导轮播
- 动态更改Twitter启动按钮上的文本,同时保留图标
- Twitter引导程序转盘不会自动启动
- jQuery-两个事件在Twitter启动后启动's模式关闭
- Twitter启动模式在初始化时显示
- Twitter启动弹出窗口触发桌面和移动平台
- Javascript倒计时与Twitter启动进度条