1 js来得到地址栏中的地址,有几种方法:
第一种:window.location.href。
第二种:document.URL。
第三种: document.location.href。
如:alert(window.location.href);
alert(document.URL);
alert(document.location.href);
2 js得到地址栏中的url中带参数的部分。就是从?开始以及之后的部分。有两种方法:
第一种:window.location.search。
第二种: document.location.search。
如:alert(window.location.search);
alert(document.location.search);
其实还是比较喜欢用document来开头的那些方法。就是href来得到全部url,而search是得到?后面参数的部分(包括?)