之前一直用ajax的方法异步请求从服务端获取,后来发现思路错了,用js获取多方便。
以下哪一个方法都可以的。
alert("window.location.href: " + window.location.href);
alert("window.location: " + window.location);
alert("location.href: " + location.href);
alert("parent.location.href: " + parent.location.href);
alert("top.location.href: " + top.location.href);
alert("document.location.href: " + document.location.href);
alert("document.URL: " + document.URL);
alert("last: "+ location.href.substring(0, location.href.lastIndexOf('/')));
以下哪一个方法都可以的。
alert("window.location.href: " + window.location.href);
alert("window.location: " + window.location);
alert("location.href: " + location.href);
alert("parent.location.href: " + parent.location.href);
alert("top.location.href: " + top.location.href);
alert("document.location.href: " + document.location.href);
alert("document.URL: " + document.URL);
alert("last: "+ location.href.substring(0, location.href.lastIndexOf('/')));
本文介绍使用JavaScript获取当前页面URL的各种方法,包括利用window.location、location、document.location等对象及其属性。
1641

被折叠的 条评论
为什么被折叠?



