下面我们举例一个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
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
var url = window.location.href; //获取当前窗口的Url; 结果:http://localhost:61768/Home/Index?id=2&age=18 var host = window.location.host; //获取当前窗口的主机名; 结果:localhost:61768 var port = window.location.port; //获取当前窗口的端口; 结果:61768 var pathname = window.location.pat
<script type=“text/javascript”> function isIE(){return navigator.appName.indexOf(“Microsoft Internet Explorer”)!=-1 && document.all;} function isIE6() {return navigator.userAgent.split(“;”)[1].toLowerCase().indexOf(“msie 6.0″)==“-1″?false:tr