js制作日历

最近在开发过程中,用到了js制作日历。

最终效果

这里写图片描述

插件

RendezVous.js

代码

<!DOCTYPE html>
<html>

    <head>
        <meta charset="UTF-8">
        <title>我的微店</title>

        <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
        <link rel="stylesheet" href="plugin/bootstrap/css/bootstrap.min.css" />
        <link rel="stylesheet" href="plugin/calendar/rendezvous.css" />
        <link rel="stylesheet" href="css/common.css" />
        <link rel="stylesheet" href="css/index.css" />
        <link rel="stylesheet" href="icons/css/icons.css" />

        <script src="js/jquery-1.10.2.min.js"></script>
        <script src="plugin/bootstrap/js/bootstrap.js"></script>
        <script src="js/util.js"></script>
        <script src="js/index.js"></script>

        <style type="text/css">
            body{background-color: #F5F5F5;}

            /*header start*/
            #header{height: 40px; line-height: 40px;}
            /*header end*/

            /*content start*/
            #content{background-color: #FFFFFF; margin-top: 45px;}
            #goods img{width:100%; height: 80%;}
            .arrow_right{width:7px; height: 12px;}
            #campaign{height: 45px;}
            .campaign{width:20px; height: 20px;}
            #box{height: 45px; line-height: 45px; background-color: #FFFFFF; width:100%;}
            .manage,.add{width:25px;}
            /*content end*/
        </style>
    </head>

    <body>
        <div id="wrapper">
            <div id="header">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-xs-3 col-sm-3 col-centered">
                            <div id="rendez-vous-french"></div>
                            <style>
                                .rendezvous-popup{width:320px;}
                                .rendezvous-datepicker{width:90%;}
                                #rendez-vous-french{width:90px; margin: 0 auto;}
                                #rendez-vous-french input{width:90px; text-align: center; height: 25px; line-height: 25px; border:none;}
                            </style>
                            <script>
                                $(function(){
                                    $("#rendez-vous-french").find("input").attr("value", "添加时间").css({"color":"#000000"});
                                })
                            </script>
                        </div>
                        <div class="col-xs-3 col-sm-3 col-centered">销量</div>
                        <div class="col-xs-3 col-sm-3 col-centered">库存</div>
                        <div class="col-xs-3 col-sm-3 col-righted" style="padding-right: 15px;">
                            <img src="img/myMiniShop/myMiniShop_pic1.png" style="width:20px;"/>
                        </div>
                    </div>
                </div>
            </div>

            <div id="content">
                <div class="container-fluid">
                    <div class="row" style="padding-top: 5px; border-bottom: #FAFAFA 1px solid;">
                        <div class="col-xs-4 col-sm-4 col-centered" id="goods">
                            <img src="img/index/goods3.png"/>
                        </div>
                        <div class="col-xs-7 col-sm-7 col-centered">
                            <div class="row" style="margin-top: 5px;"><div class="col-xs-12 col-sm-12 col-lefted">无印良品MUJI 6角迷你水笔套装(10色)</div></div>
                            <div class="row"><div class="col-xs-12 col-sm-12 col-lefted"><font class="red">&yen;39.00</font></div></div>
                            <div class="row gray" style="margin-top: 22px;">
                                <div class="col-xs-6 col-sm-6 col-lefted">销量 20万</div>
                                <div class="col-xs-6 col-sm-6 col-lefted">收藏 15万</div>
                            </div>
                            <div class="row gray">
                                <div class="col-xs-6 col-sm-6 col-lefted">库存 9999+</div>
                                <div class="col-xs-6 col-sm-6 col-lefted">添加 2016/12/14</div>
                            </div>
                        </div>
                        <div class="col-xs-1 col-sm-1 col-centered">
                            <span class="arrow_right"></span>
                        </div>

                        <script>
                            $(function(){
                                var height = $("#content").children(".container-fluid").children(".row").eq(0).css("height");
//                              console.log(height);
                                $(".arrow_right").parent().css("line-height", height);
                            })
                        </script>
                    </div>
                    <div class="row" id="campaign">
                        <div class="col-xs-3 col-sm-3 col-centered"></div>
                        <div class="col-xs-3 col-sm-3 col-centered gray">
                            <span class="campaign_copy_gray campaign"></span><br />
                            复制
                        </div>
                        <div class="col-xs-3 col-sm-3 col-centered gray">
                            <span class="campaign_link_gray campaign"></span><br />
                            推广
                        </div>
                        <div class="col-xs-3 col-sm-3 col-centered red">
                            <span class="campaign_share_red campaign"></span><br />
                            分享
                        </div>
                    </div>
                </div>
            </div>

            <div id="box">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-xs-6 col-sm-6 col-centered"><img class="manage" src="img/myMiniShop/myMiniShop_pic6.png"/>添加商品</div>
                        <div class="col-xs-6 col-sm-6 col-centered"><img class="add" src="img/myMiniShop/myMiniShop_pic5.png"/>批量管理</div>
                    </div>
                </div>
            </div>

            <!--<script>
                $(function(){
                    var height = ($(window).height() + "").split("px")[0];
                    var footerHeight = ($("#footer").css("height") + "").split("px")[0];
                    var boxHeight = ($("#box").css("height") + "").split("px")[0];
                    $("#box").css("position","fixed").css("top", height - footerHeight - boxHeight + "px");
                    console.log(height - footerHeight - boxHeight + "px");
                })
                window.onresize = function(){
                    var height = ($(window).height() + "").split("px")[0];
                    var footerHeight = ($("#footer").css("height") + "").split("px")[0];
                    var boxHeight = ($("#box").css("height") + "").split("px")[0];
                    $("#box").css("position","fixed").css("top", height - footerHeight - boxHeight + "px");
                    console.log(height - footerHeight - boxHeight + "px");
                }
            </script>-->

            <div id="footer">
                <div class="container-fluid">
                    <div class="row" style="height: 40px; line-height: 32px;">
                        <div class="col-xs-3 col-sm-3 col-centered toggle" id="shop">
                            <div class="redIcon"></div>
                            <div class="red">商城</div>
                        </div>
                        <div class="col-xs-3 col-sm-3 col-centered toggle" id="myShop">
                            <div class="grayIcon"></div>
                            <div class="gray">开店</div>
                        </div>
                        <div class="col-xs-3 col-sm-3 col-centered toggle" id="message">
                            <div class="grayIcon"></div>
                            <div class="gray">消息</div>
                        </div>
                        <div class="col-xs-3 col-sm-3 col-centered toggle" id="member">
                            <div class="grayIcon"></div>
                            <div class="gray">会员</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <script src="plugin/calendar/example/js/syntaxhighlighter/shCore.js"></script>
        <script src="plugin/calendar/example/js/syntaxhighlighter/shBrushJScript.js"></script>
        <script src="plugin/calendar/example/js/syntaxhighlighter/shBrushXml.js"></script>
        <script src="plugin/calendar/example/js/syntaxhighlighter/shBrushCss.js"></script>
        <script src="plugin/calendar/rendezvous.js"></script>
        <script src="plugin/calendar/example/js/app.js"></script>
    </body>

</html>
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"> //创建一个数组,用于存放每个月的天数 function montharr(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11)  { this[0] = m0; this[1] = m1; this[2] = m2; this[3] = m3; this[4] = m4; this[5] = m5; this[6] = m6; this[7] = m7; this[8] = m8; this[9] = m9; this[10] = m10; this[11] = m11; } //实现月历 function calendar() { var monthNames = "JanFebMarAprMayJunJulAugSepOctNovDec"; var today = new Date(); var thisDay; var monthDays = new montharr(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); year = today.getYear() +1900; thisDay = today.getDate(); if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) monthDays[1] = 29; nDays = monthDays[today.getMonth()]; firstDay = today; firstDay.setDate(1); testMe = firstDay.getDate(); if (testMe == 2) firstDay.setDate(0); startDay = firstDay.getDay(); document.write("<div id='rili' style='position:absolute;width:140px;left:300px;top:100px;'>")  document.write("<TABLE width='217' BORDER='0' CELLSPACING='0' CELLPADDING='2' BGCOLOR='#0080FF'>") document.write("<TR><TD><table border='0' cellspacing='1' cellpadding='2' bgcolor='Silver'>"); document.write("<TR><th colspan='7' bgcolor='#C8E3FF'>"); var dayNames = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六"); var monthNames = new Array("1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"); var now = new Date(); document.writeln("<FONT STYLE='font-size:9pt;Color:#330099'>" + "公元 " + now.getYear() + "年" + monthNames[now.getMonth()] + " " + now.getDate() + "日 " + dayNames[now.getDay()] + "</FONT>"); document.writeln("</TH></TR><TR><TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>日</FONT></TH>"); document.writeln("<th bgcolor='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>一</FONT></TH>"); document.writeln("<TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>二</FONT></TH>"); document.writeln("<TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>三</FONT></TH>"); document.writeln("<TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>四</FONT></TH>"); document.writeln("<TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>五</FONT></TH>"); document.writeln("<TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>六</FONT></TH>"); document.writeln("</TR><TR>"); column = 0; for (i=0; i<startDay; i++) { document.writeln("\n<TD><FONT STYLE='font-size:9pt'> </FONT></TD>"); column++; } for (i=1; i<=nDays; i++) { if (i == thisDay) { document.writeln("</TD><TD ALIGN='CENTER' BGCOLOR='#FF8040'><FONT STYLE='font-size:9pt;Color:#ffffff'><B>") } else { document.writeln("</TD><TD BGCOLOR='#FFFFFF' ALIGN='CENTER'><FONT STYLE='font-size:9pt;font-family:Arial;font-weight:bold;Color:#330066'>"); } document.writeln(i); if (i == thisDay) document.writeln("</FONT></TD>") column++; if (column == 7) { document.writeln("<TR>");  column = 0; } } document.writeln("<TR><TD COLSPAN='7' ALIGN='CENTER' VALIGN='TOP' BGCOLOR='#0080FF'>") document.writeln("<FORM NAME='clock' onSubmit='0'><FONT STYLE='font-size:9pt;Color:#ffffff'>") document.writeln(" 现在时间:<INPUT TYPE='Text' NAME='face' ALIGN='TOP'></FONT></FORM></TD></TR></TABLE>") document.writeln("</TD></TR></TABLE></div>"); } </SCRIPT>

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值