zoukankan      html  css  js  c++  java
  • js获取服务器时间戳

    <!DOCTYPE html>

    <html>

    <head>

    <title>ajax</title>

    </head>

    <body>

    <script src="js/dui.js"></script>

    <script>

    // 方法一

    ajax('/', function (data, obj) {

      alert(obj.getResponseHeader("Date"));

    });

    // 方法二

    var xmlhttp = null;

    if (window.ActiveXObject) xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

    else xmlhttp = new XMLHttpRequest();

    xmlhttp.open('get', "/", false);

    xmlhttp.setRequestHeader('If-Modified-Since', 'q');

    xmlhttp.send();

    var timestr = xmlhttp.getResponseHeader('Date');

    var date = new Date(timestr);

    alert(date);

    </script>

    </body>

    </html>

    var utlis = (function (win, doc) {
    var module = {};

    // 获取服务器时间
    module.servertime = function (options) {
    var xmlhttp = window.ActiveXObject ? new ActiveXObject('Microsoft.XMLHTTP') : xmlhttp = new XMLHttpRequest();

    xmlhttp.open('get', '/', false);
    xmlhttp.setRequestHeader('If-Modified-Since', 'q');
    xmlhttp.send();

    return new Date(xmlhttp.getResponseHeader('Date'));
    };

    return module;
    })(window, document);

  • 相关阅读:
    抽奖概率算法
    redis启动异常
    php如何快速读取大文件
    nginx反向代理解决跨域
    sublime修改侧边栏字体
    curl
    公众号开发一
    数组
    在windows下用vagrant建立lnmp开发环境
    gets--vs--fgets
  • 原文地址:https://www.cnblogs.com/baie/p/4060699.html
Copyright © 2011-2022 走看看