日期和天气交替显示

<html>
<head runat="server">
    <title>timeAndweather</title>
    <meta http-equiv="x-ua-compatible" content="ie=7" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="css/style.css" rel="stylesheet" type="text/css" />
    <script src="javaScript/jquery-1.2.6-cn-vsdoc.js" type="text/javascript"></script>
    <script src="javaScript/jquery-1.2.6-cn.js" type="text/javascript"></script>
    <script src="javaScript/realtime.js" type="text/javascript"></script>
    <base target="_self" />
    <script language="JavaScript" type="text/javascript">
       
        $(function(){
            setTimeout("WeatherShow()",3000);
        });
        function WeatherShow()
        {
            $("#time").fadeOut(1000,
                function (){
                    $("#weather").show(2000,function() {setTimeout("TimeShow()",3000);});
                }
            );
        }
        function TimeShow()
        {
            $("#weather").hide(1000,//执行完函数后执行里面的方法
                function (){
                    $("#time").fadeIn(2000,function() {setTimeout("WeatherShow()",3000);});//使用计时器让函数调用,推迟2秒
                }
            );
         
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
            <td>
                <img src="images/index_01.jpg" width="1000" height="210" alt="" />
            </td>
        </tr>
        <tr>
            <td>
                <table width="100%" border="0" cellspacing="0" cellpadding="0" class="td">
                    <tr>
                        <td width="190" class="fon" valign="middle" align="center">
                            <table align="center">
                                <tr>
                                    <td>
                                        <div id="time">

                                            <script language="javascript">timer_begin(1);aaaa</script>

                                        </div>
                                    </td>
                                    <td>
                                        <div id="weather" style="display: none;">
                                            <iframe src=" http://m.weather.com.cn/m/pn6/weather.htm?id=101101001T " width="130"
                                                height="20" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0"
                                                allowtransparency="true" scrolling="no"></iframe>
                                        </div>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    </form>
</body>
</html>
realtime.js文件

function realTime(index) {
    var d = new Date();
    var dayDes = new Array("天", "一", "二", "三", "四", "五", "六");
    var t = document.all("timerbar_" + index);
    if (t) {
        t.innerHTML = d.getFullYear() + "年" + (((d.getMonth() + 1) + "").length == 2 ? (d.getMonth() + 1) : "0" + (d.getMonth() + 1)) + "月" + ((d.getDate() + "").length == 2 ? d.getDate() : "0" + d.getDate()) + "日 星期" + dayDes[d.getDay()];
    }
    setTimeout("realTime(" + index + ");", 1000);
}

function timer_begin(index) {
    document.write("<span id='timerbar_" + index + "' align='center' style='font-size:12px;color:#fff;'></span>");
    realTime(index);
}
style.css文件

body{margin:  0px 0px 0px 0px;background-color: #eeeeee;}
.fon{font-family: "宋体";font-size: 12px;color: #ffffff;}
.td{ background: url(../images/index_03.gif) repeat-x;height: 35px;}
A img {BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BORDER-BOTTOM-STYLE: none} /*图片无边框*/

posted on 2011-01-08 10:47  杜军(橘仙)  阅读(217)  评论(0编辑  收藏  举报

导航