js获取服务器时间
来源:互联网 发布:淘宝双查号是什么意思 编辑:程序博客网 时间:2024/05/20 15:41
<p id="time"></p><script>ajax() function ajax(option){ var xhr = null; if(window.XMLHttpRequest){ xhr = new window.XMLHttpRequest(); }else{ // ie xhr = new ActiveObject("Microsoft") } // 通过get的方式请求当前文件 xhr.open("get","/"); xhr.send(null); // 监听请求状态变化 xhr.onreadystatechange = function(){ var time = null, curDate = null; if(xhr.readyState===2){ // 获取响应头里的时间戳 time = xhr.getResponseHeader("Date"); console.log(xhr.getAllResponseHeaders()) curDate = new Date(time); document.getElementById("time").innerHTML = "服务器时间是:"+curDate.getFullYear()+"-"+(curDate.getMonth()+1)+"-"+curDate.getDate()+" "+curDate.getHours()+":"+curDate.getMinutes()+":"+curDate.getSeconds(); } } }</script>
原文地址:http://www.cnblogs.com/wangmeijian/p/4442830.html
0 0
- JS 获取服务器时间
- js获取服务器时间
- JS获取服务器时间
- js获取服务器时间
- js获取服务器时间
- js获取服务器时间
- js获取服务器时间
- js 获取服务器时间
- js获取服务器当前时间
- js 获取 服务器系统时间
- JS服务器获取时间倒计时
- 使用js获取服务器时间
- js如何获取服务器时间
- js,jquery获取服务器时间
- js获取本地时间、服务器时间、倒计时
- JS获取服务器时间的方法
- 利用js获取当前本地时间和服务器时间
- js向服务器发送请求,获取服务器时间
- 设计模式(七)--策略模式
- sublime text插件
- Github Desktop上传项目
- myeclipse导入的工程无法deploy
- 三元组压缩矩阵及解压
- js获取服务器时间
- Spring实战回炉贴-2
- python3.6之Django项目--virtualenv安装
- 自定义控件之横向选择控件
- ORACLE PL/SQL编程详解之一: PL/SQL 程序设计简介
- Python--matplotlib绘图可视化知识点整理
- Debug基本操作
- Ajax简要分析使用
- CountDownLatch使用