• λ我爱Aspx >> C#.Net >> Javascript利用xmlhttp获得服务器时钟的方法_ASP技巧
  • Javascript利用xmlhttp获得服务器时钟的方法_ASP技巧

  • :aspxer  Դ:internet  :2007-4-28 23:47:07  ؼ:asp,xml,javascript
  • clock.asp

    -----------------------------------

    < %

    Response.Expires = -1

    dim a

    a=now()

    Response.Write formatdatetime(a,2) & " " & formatdatetime(a,3)% >

    -----------------------------------

    mytime.htm

    -----------------------------------

    <html>

    <body topmargin="0" leftmargin="0" style="background-color:#e0d0c0">

    <table width="98%"><tr>

    <td align="center" width="50%" style="font-size:16;font-weight:bold;">长春轨道客车股份有限公司产品计划价格计算程序</td>

    <td width="50%" align="right">

    <input type="text" style="font-size:12px;border:none;background:;" size="18" id="myTime" />

    </td>

    </tr>

    </table>

    </body>

    </html>

    <script language="javascript">

    //简单方法,用最简单的代码实现,但是有很多错误隐患的

    /*

    function getClock()

    {

    var XmlHttp = new ActiveXObject("Msxml2.XMLHTTP")

    XmlHttp.Open( "POST", "clock.asp", false );

    XmlHttp.Send();

    if (XmlHttp.status == 200) myTime.value=XmlHttp.responseText;

    window.setTimeout("getClock()","1000")

    }

    setInterval("getClock()",1000);

    */

    </script>

    如果为了能使程序的兼容性和健壮性更强,可以将mytime.htm改成如下的

    -----------------------------------

    mytime.htm

    -----------------------------------

    <html>

    <body topmargin="0" leftmargin="0" style="background-color:#e0d0c0">

    Ҷƪл˵?
  • һƪ解读 C# 中的正则表达式
    һƪXMLHttpRequest和AJAX虎视Web应用开发_Ajax