• 时间显示的位置


    第一种方式:

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>系统时间</title>
    <script language="javascript" type="text/javascript">
    <!--
    //获得当前时间,刻度为一千分一秒
    var initializationTime=(new Date()).getTime();
    function showLeftTime()
    {
    var now=new Date();
    var year=now.getYear();
    var month=now.getMonth();
    var day=now.getDate();
    var hours=now.getHours();
    var minutes=now.getMinutes();
    var seconds=now.getSeconds();
    document.all.show.innerHTML=""+year+"年"+month+"月"+day+"日 "+hours+":"+minutes+":"+seconds+"";
    //一秒刷新一次显示时间
    var timeID=setTimeout(showLeftTime,1000);
    }
    //-->
    </script>
    </head>
    <body onload="showLeftTime()">
    <div id="time" style="margin-top:200px; margin-left:600px;">
    <label id="show">显示时间的位置</label>
    </div>
    </body>
    </html>

    第二种的方式:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    </head>

    <body>
    <div id="webjx" style="margin-top:200px; margin-left:200px;">
    <span id=nowDate></span>
    <span id=nowTime></span>
    <script><!--
    var ns4up1 = (document.layers) ? 1 : 0; // browser sniffer

    var ie4up1 = (document.all&&(navigator.appVersion.indexOf("MSIE 4") == -1)) ? 1 : 0;

    var ns6up1 = (document.getElementById&&!document.all) ? 1 : 0;

    function nowclock() {
    if (!ns4up1 && !ie4up1 && !ns6up1) return false;
    var digital = new Date();
    var hours = digital.getHours();
    var minutes = digital.getMinutes();
    var seconds = digital.getSeconds();
    var day = digital.getDate();
    var month = digital.getMonth() + 1;
    var year = digital.getYear();
    var amOrPm = "AM";
    if (hours > 11) amOrPm = "PM";
    if (hours > 12) hours = hours - 12;
    if (hours == 0) hours = 12;
    if (minutes < 10) minutes = "0" + minutes;
    if (seconds < 10) seconds = "0" + seconds;
    if (day < 10) day = "0" + day;
    if (month < 10) month = "0" + month;
    dispTime = hours + ":" + minutes + ":" + seconds + " " + amOrPm;
    dispDate = year + "年" + month + "月" + day+ "日, " ;
    if (ns4up1) {
    document.layers.nowTime.document.write(dispTime);
    document.layers.nowTime.document.close();
    document.layers.nowDate.document.write(dispDate);
    document.layers.nowDate.document.close();
    } else if (ns6up1){
    document.getElementById("nowTime").innerHTML = dispTime;
    document.getElementById("nowDate").innerHTML = dispDate;
    } else if (ie4up1){
    nowTime.innerHTML = dispTime;
    nowDate.innerHTML = dispDate;
    } setTimeout("nowclock()", 1000);
    } nowclock();
    //-->
    </script>
    </div>
    </body>
    </html>

  • 相关阅读:
    awk中NF的使用
    mysql5.7 column cannot be null
    mysqldump的简单使用
    mysql 删表引出的问题
    centos6.6 下安装mysql5.7
    从高的角度看自动化测试
    java提示找不到或无法加载主类
    修改chrome插件
    jenkins修改时区
    Rest-assured 写日志到 log4j
  • 原文地址:https://www.cnblogs.com/costa92/p/3682539.html
Copyright © 2020-2023  润新知