zoukankan      html  css  js  c++  java
  • asp.net 答题:浮动倒计时

    前台:

    <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
    <!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 id="Head1" runat="server">
    <title>无标题页</title>
    <!--***********开始*************-->
    <script type="text/javascript">
    //<![CDATA[
    var tips; var theTop = 200/*这是默认高度,越大越往下*/; var old = theTop;
    function initFloatTips() {
    tips = document.getElementById('floatTips');
    moveTips();
    };
    function moveTips() {
    var tt=50;
    if (window.innerHeight) {
    pos = window.pageYOffset
    }
    else if (document.documentElement && document.documentElement.scrollTop) {
    pos = document.documentElement.scrollTop
    }
    else if (document.body) {
    pos = document.body.scrollTop;
    }
    pos=pos-tips.offsetTop+theTop;
    pos=tips.offsetTop+pos/10;
    if (pos < theTop) pos = theTop;
    if (pos != old) {
    tips.style.top = pos+"px";
    tt=10;
    }
    old = pos;
    setTimeout(moveTips,tt);
    }
    //!]>
    </script>
    <style type="text/css">
    div#floatTips{
    position:absolute;
    border:solid 1px #777;
    padding:3px;
    top:250px;
    right:50px;
    300px;
    background:#cccccc;
    color:white;
    }
    </style>
    <script language="JavaScript" type="text/javascript">
    function count_down()
    {
    window.setTimeout("count_down()", 1000);
    var a=document.getElementById("HiddenField1").value;

    testDay=new Date(a);
    today=new Date();

    time=(testDay.getTime()-today.getTime())/(24*60*60*1000);
    day=Math.floor(time);
    time=(time-day)*24;
    hour=Math.floor(time);
    time=(time-hour)*60;
    minute=Math.floor(time);
    time=(time-minute)*60;
    second=Math.floor(time);

    show_time.innerHTML="剩余答题时间:"+day+""+hour+"小时"+minute+""+second+"";
    }
    </script>
    </head>

    <body onload="count_down();initFloatTips();">
    <form id="form1" runat="server">

    <div id="floatTips">
    <div id="show_time" style="font-size: 12px; color: #ff6600;"> </div></div>
    <asp:HiddenField ID="HiddenField1" runat="server" />
    <!--**********结束***************-->
    <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#F7F7F7">
    <tr>
    <td height="2101"> </td>
    </tr>
    </table>
    </form>
    </body>
    </html>

    后台:

    using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;

    public partial class _Default : System.Web.UI.Page
    {
    public string a = "2012/3/9 17:40:00"; //此处动态读取数据库时间
    protected void Page_Load(object sender, EventArgs e)
    {
    this.HiddenField1.Value = a;
    }
    }



  • 相关阅读:
    杭电 Problem
    杭电Problem 5053 the sum of cube 【数学公式】
    杭电 Problem 2089 不要62 【打表】
    杭电 Problem 4548 美素数【打表】
    杭电 Problem 2008 分拆素数和 【打表】
    杭电 Problem 1722 Cake 【gcd】
    杭电 Problem 2187 悼念512汶川大地震遇难同胞——老人是真饿了【贪心】
    杭电Problem 1872 稳定排序
    杭电 Problem 1753 大明A+B
    东北林业大 564 汉诺塔
  • 原文地址:https://www.cnblogs.com/wifi/p/2387394.html
Copyright © 2011-2022 走看看