EXTJS4.2 时间动态刷新显示

复制代码
function clockGo() {
    Ext.TaskManager.start({
        run: function () {
            //Ext.getCmp("clock").setText(Ext.Date.format(new Date(), 'g:i:s A'));
            var showtime = document.getElementById("time");
            var now = new Date();
            var date = now.toLocaleString();// //获取日期与时间 如 2014年6月25日 下午4:45:06
            var hours = now.getHours();
            var minutes = now.getMinutes();
            var seconds = now.getSeconds();
            if (hours < 10) hours = "0" + hours;
            if (minutes < 10) minutes = "0" + minutes;
            if (seconds < 10) seconds = "0" + seconds;
            //var timestr = hours + ":" + minutes + ":" + seconds;
            var timestr = date ;
            showtime.innerHTML = timestr;
        },
        interval: 1000//每秒刷新一次
    });
}

//顶部面板
var north = new Ext.Panel({
    frame: true,
    plain: true,
    height: 56,
    border: false,
    region: 'north',
    items: [{
        baseCls: 'x-plain',
        border: false,
        height: 56,
        html: " <TABLE cellSpacing=0 cellPadding=0 width=100% background='/images/header_bg.jpg' border=0> <TR height=56><TD width=260><IMG height=56 src='/images/header_left.jpg' width=260></TD><TD style='FONT-WEIGHT: bold; COLOR: #fff; PADDING-TOP: 20px' align=right>当前时间:<span id=time></span>&nbsp;&nbsp;</div>当前用户:admin &nbsp;&nbsp; <A style='COLOR: #fff' href=''>修改口令</A> &nbsp;&nbsp; <A style='COLOR: #fff' onclick='if (confirm('确定要退出吗?')) return true; else return false;' href='' target=_top>退出系统</A> </TD><TD align=right width=268><IMG height=56 src='/images/header_right.jpg' width=268></TD></TR></TABLE><TABLE cellSpacing=0 cellPadding=0 width=100% border=0><TR bgColor=#1c5db6 height=4><TD></TD></TR></TABLE>"
    }],
    listeners: {
        'render': function () {
            clockGo();
        }
    }
});
复制代码

 

posted @   秋风过、枯叶落  阅读(656)  评论(0编辑  收藏  举报
编辑推荐:
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
阅读排行:
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 字符编码:从基础到乱码解决
点击右上角即可分享
微信分享提示