<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    The important thing in life is to have a great aim , and the determination

    常用鏈接

    統計

    IT技術鏈接

    保險相關

    友情鏈接

    基金知識

    生活相關

    最新評論

    簡單的JS日期表示

    代碼如下:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    <META NAME="Generator" CONTENT="EditPlus">
    <META NAME="Author" CONTENT="">
    <META NAME="Keywords" CONTENT="">
    <META NAME="Description" CONTENT="">
    </HEAD>

    <BODY>
    <script language="javascript">
    todayDate = new Date();
    date = todayDate.getDate();
    month= todayDate.getMonth() +1;
    year= todayDate.getYear();
    document.write("? 今天是")
    document.write("<br>")
    if(navigator.appName == "Netscape")
    {
    ?document.write(1900+year);
    ?document.write("年");
    ?document.write(month);
    ?document.write("月");
    ?document.write(date);
    ?document.write("日");
    ?document.write("<br>")
    }
    if(navigator.appVersion.indexOf("MSIE") != -1)
    {
    document.write(year);
    document.write("年");
    document.write(month);
    document.write("月");
    document.write(date);
    document.write("日");
    document.write("<br>")
    }
    if (todayDate.getDay() == 5) document.write("? 星期五")
    if (todayDate.getDay() == 6) document.write("? 星期六")
    if (todayDate.getDay() == 0) document.write("? 星期日")
    if (todayDate.getDay() == 1) document.write("? 星期一")
    if (todayDate.getDay() == 2) document.write("? 星期二")
    if (todayDate.getDay() == 3) document.write("? 星期三")
    if (todayDate.getDay() == 4) document.write("? 星期四")

    </script>
    </BODY>
    </HTML>

    源代碼解釋:

    todayDate = new Date();
    當定義一個新的對象時,通常使用“new”操作符。在這里,就是創建了日期對象。
    date = todayDate.getDate();

    getDate()是Date對象的一種方法,其功能是獲得當前的日期。
    month= todayDate.getMonth() + 1 ;
    ;
    getMonth()是Date對象的一種方法,其功能是獲得當前的日期,由于月份是從0開始的,所以這里要“+1”。
    year= todayDate.getYear() getYear()是Date對象的一種方法,其功能是獲得當前的年份。
    document.write("今天是") document.write("<br>") 輸出“今天是”
    if(navigator.appName == "Netscape") { document.write(1900+year); document.write("年"); document.write(month); document.write("月"); document.write(date); document.write("日");
    document.write("<br> ") }
    如果瀏覽器是Netscape,輸出今天是“year”+“年”+“month”+“月”+“date”+“日”,其中年要加1900。
    if(navigator.appVersion.indexOf("MSIE") != -1) { document.write(year); document.write("年"); document.write(month); document.write("月"); document.write(date); document.write("日");
    document.write("<br> ") }
    如果瀏覽器是IE,直接輸出今天是“year”+“年”+“month”+“月”+“date”+“日”。
    document.write("") ; 在“日期”與“星期”之間輸入一個空格。
    if (todayDate.getDay() == 5) document.write("星期五");
    if (todayDate.getDay() == 6) document.write("星期六");
    if (todayDate.getDay() == 0) document.write("星期日");
    if (todayDate.getDay() == 1) document.write("星期一");
    if (todayDate.getDay() == 2) document.write("星期二");
    if (todayDate.getDay() == 3) document.write("星期三");
    if (todayDate.getDay() == 4) document.write("星期四")
    getDay()是Date對象的一種方法,其功能是獲得當前是星期幾。document.write輸出今天是“星期幾”。

    posted on 2007-03-23 11:18 鴻雁 閱讀(423) 評論(0)  編輯  收藏

    主站蜘蛛池模板: 亚洲jjzzjjzz在线观看| 久久精品国产亚洲av麻| 亚洲中文字幕精品久久| 免费在线视频你懂的| 亚洲欧洲国产精品你懂的| 青柠影视在线观看免费高清| 久久精品夜色噜噜亚洲A∨| 青青青视频免费观看| 国产精品亚洲美女久久久| 国产成人无码精品久久久免费| a级毛片高清免费视频就| 亚洲理论电影在线观看| 十八禁在线观看视频播放免费| 永久免费看mv网站入口| 国产精品亚洲а∨无码播放不卡| 国产精品色午夜视频免费看| 美女啪啪网站又黄又免费| 亚洲精品国产精品乱码不卡| aaa毛片免费观看| 亚洲综合一区二区精品导航| 91制片厂制作传媒免费版樱花 | 亚洲丶国产丶欧美一区二区三区| 性短视频在线观看免费不卡流畅| 亚洲精品视频免费看| 国产无人区码卡二卡三卡免费| 亚洲理论在线观看| 天天操夜夜操免费视频| 爱情岛论坛免费视频| 亚洲精品夜夜夜妓女网| av免费不卡国产观看| 小说专区亚洲春色校园| 亚洲热妇无码AV在线播放| 亚洲视频在线免费看| 国产精品亚洲精品爽爽| 亚洲线精品一区二区三区| 国产成人精品免费视频大| 日本高清不卡中文字幕免费| 无码乱人伦一区二区亚洲| 免费高清在线影片一区| 两个人日本免费完整版在线观看1| 国产精品久久久亚洲|