javascript一般只是用来在客户端运行,
如果要获得服务器的时间,建议采用动态语言,就在你登陆的时候用动态语言获得时间再显示在页面上

解决方案 »

  1.   

    要实现这个效果,必须要与服务器交流,
    js与服务器交流的有效手段可以用xmlhttp,参考下面的代码:  Dim Timer, xml
      Set xml = Server.CreateObject("Microsoft.XMLHTTP")
      
      xml.Open "GET", ServerURL, False
      ' ServerURL是你获取时间的页面地址,比如gettime.asp,该文件可以就写Response.write now()
      xml.Send   Timer= xml.ResponseBody
      Timer= BytesToBstr(strPageData,"GB2312")
      Set xml = Nothing
                        Response.write Timer
      

  2.   

    上面的代码有误~~
    应改写成如下:   var Timer, xml;
      xml = new ActiveXObject("Microsoft.XMLHTTP");
      
      xml.open("GET",ServerURL,false);
      //ServerURL是你获取时间的页面地址,比如gettime.asp,该文件可以就写Response.write now()
      xml.send();   Timer= xml.responseBody;
      xml = null;
      textbox的ID.text
      

  3.   

    对不起,对不起,是我没有说清楚,我用的是ASP.NET
      

  4.   

    xmlhttp具体使用方法参考:http://www.channel7.cn/2004/11-18/14458.html
      

  5.   

    一样的,js的使用与asp还是asp.net没有任何关系
      

  6.   


    var Timer, xml;
      xml = new ActiveXObject("Microsoft.XMLHTTP");
      
      xml.open("GET",ServerURL,false);
      //ServerURL是你获取时间的页面地址,比如gettime.asp,该文件可以就写Response.write now()
      xml.send();   Timer= xml.responseBody;
      xml = null;
      textbox的ID.text
    这个应该写在判断Onclick时间中吗?不过那个ServerURL是获取时间的页面地址吗?就是我点击按钮的那个页面?那么这段代码应该写在显示页的JavaScript中吗?
      

  7.   

    我用的是一个客户端的控件来显示的
    <input disabled type="text" size="7" name="DJSJ" STYLE="WIDTH:68px">
    那么,最后的那句textbox的ID.text应该怎么办呢?拜托稍微解释一下,谢谢啦~
      

  8.   

    1.上面那段就是写在onclick事件中的
    2.ServerURL就是输出时间的文件地址
    3.最后那句就是你希望把时间显示在哪里,
    照你的要求,写成这样:DJSJ.text=Timer
      

  9.   

    嗯,有错误,我这个人比较笨,不好意思,给你添麻烦了
    我是这么写的那个按钮
    <input onclick="djjl(this)" type="button" value="登记" name="DJ">然后那个JavaScript是这么写
    function djjl(obj) //判断违章登记
    {
    if(obj.name=="DJ")                                    
    {
    document.EnrolForm.action="OptionDo.aspx?enrolFind=1&Wzjlid=<%=wzjlid%>";
    EnrolForm.submit();

    var Timer, xml;
    xml = new ActiveXObject("Microsoft.XMLHTTP");
      
    xml.open("GET",/Move/Move1.aspx,false);
    //ServerURL是你获取时间的页面地址,比如gettime.asp,该文件可以就写Response.write now()
    xml.send(); Timer= xml.responseBody;
    xml = null;
    DJSJ.text=Timer                     
    }else
    {
    location.assign("/Move/Err.aspx");            
    }

    }
    其中Move1是我想显示系统时间的页面,请您帮看一下是我什么地方写错了,辛苦了~~
      

  10.   

    你这个应该先用xmlhttp把时间获取出来,放到隐藏表单里,再同时submit.