function getOS() { // 获取当前操作系统 var os; if (navigator.userAgent.indexOf('Android') > -1 || navigator.userAgent.indexOf('Linux') > -1) { os = 'Android'; } else if (navigator.userAgent.indexOf('iPhone') > -1) { os = 'iOS'; } else if (navigator.userA…
<html> <head> <title></title> <script type="text/javascript"> var WshShell; var safe = false; //*** 应该初始化为 false try { WshShell = new ActiveXObject("WScript.Shell"); } catch (e) { safe = true; //*** 上面的失败了…
当我们使用ajax发起请求时,经常需要获取请求返回的头信息.默认情况下,js货可以获取如下头信息: Cache-Control Content-Language Content-Type Expirs Last-Modified Pragma ajax请求完成,会返回xhr(XMLHTTPRequest)对象,这里面会包含返回的头信息,其中有两个方法,如下: getAllResponseHeaders():获取全部可默认可获取的头信息 getResponseHeader(key):获取指定头信息…
下面我们举例一个URL,然后获得它的各个组成部分: http://i.cnblogs.com/EditPosts.aspx?opt=1 window.location.href (设置或获取整个 URL 为字符串) var test = window.location.href; alert(test); // 返回:http://i.cnblogs.com/EditPosts.aspx?opt=1 window.location.protocol (设置或获取 URL 的协议部分) var t…
1.js 判断IOS版本号 先来观察 iOS 的 User-Agent 串: iPhone 4.3.2 系统:Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5iPone 5.1 系统:Mozilla/5.0 (iPhone; U; CPU iPhone…
document.location 这个对象包含了当前URL的信息 location.host 获取port号 location.hostname 设置或获取主机名称 location.href 设置或获取整个URL location.port设置或获取URL的端口号 location.search 设置或获取href属性中跟在问号后面的部分 如:?aaa=123&bbb=456$ccc=789 js中window.location的应用 URL即:统一资源定位符 (Uniform Resour…
个人博客 地址:http://www.wenhaofan.com/article/20181125220342 在开发AutuBlog项目时需要做后台的登录记录,想起浏览器的User-Agent,于是尝试从浏览器的请求头中获取一些有用的信息. 通过总结大量请求头数据写出以下正则 ^Mozilla/\d\.\d\s+\(+.+?\) 该正则含义为 以Mozilla/开头+浏览器版本格式为数字.数字+空格+(+任意字符串+匹配第一个) 测试数据 Mozilla/5.0 (Macintosh; Int…
<script type="text/javascript"> function Location() {}; Location.prototype.getLocation = function (callback) { var options = { enableHighAccuracy: true, maximumAge: 1000 }; this.callback = Object.prototype.toString.call(callback) == "…
设置或获取对象指定的文件名或路径. alert(window.location.pathname) 设置或获取整个 URL 为字符串. alert(window.location.href); 设置或获取与 URL 关联的端口号码. alert(window.location.port) 设置或获取 URL 的协议部分. alert(window.location.protocol) 设置或获取 href 属性中在井号“#”后面的分段. alert(window.location.hash) 设…
设置或获取对象指定的文件名或路径.<script>alert(window.location.pathname)</script> 设置或获取整个 URL 为字符串.<script> alert(window.location.href);</script>设置或获取与 URL 关联的端口号码.<script>alert(window.location.port)</script> 设置或获取 URL 的协议部分.<script…