知行合一

终于找到了在 ie firefox 下都正常的当前时间显示

网上有很多的js ,ie下能正常显示,但在firefox下的 年老是有问题,现在  终于找到了在 ie firefox 下都正常的当前时间显示,贴出来备用,也希望对你有用…….代码如下:

<DIV id=time>当前时间
<SCRIPT>document.getElementById(‘time’).innerHTML=new Date().toLocaleString()+’ 星期’+’日一二三四五六’.charAt(new Date().getDay());setInterval(“document.getElementById(‘time’).innerHTML=new Date().toLocaleString()+’ 星期’+’日一二三四五六’.charAt(new Date().getDay());”,1000);</SCRIPT>
</DIV>
自己在合适位置放上,也可以加上自己的样式……..

赞(0) 打赏
未经允许不得转载:嘟嘟鱼 » 终于找到了在 ie firefox 下都正常的当前时间显示
分享到: 更多 (0)

评论 2

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. #-49

    如果我只需要取 时:分:秒 呢? 又该如何显示?

    游客16年前 (2008-01-02)回复
  2. #-48

    <body onload=startclock()>

    <form name="clock">
    <script language="JavaScript">
    var timerID = null;
    var timerRunning = false;
    function stopclock (){
    if(timerRunning)
    clearTimeout(timerID);
    timerRunning = false;}
    function startclock () {
    stopclock();
    showtime();}
    function showtime () {
    var now = new Date();
    var hours = now.getHours();
    var minutes = now.getMinutes();
    var seconds = now.getSeconds()
    var timeValue = ''
    timeValue += ((hours >12) ? hours -12 :hours)
    timeValue += ((minutes < 10) ? ":0" : ":") + minutes
    timeValue += ((seconds < 10) ? ":0" : ":") + seconds
    document.clock.thetime.value = timeValue;
    timerID = setTimeout("showtime()",1000);
    timerRunning = true;}
    </script>
    <input name="thetime" style="font-size: 9pt;color:#000000;border:1px solid #FFFFFF; ; " size="28"></form>

    </body>

    嘟嘟鱼16年前 (2008-01-02)回复

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏