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();

        }

    }

});

 

你可能感兴趣的:(extjs4)