JS获取当前页面URL的方法
1.JS获取当前页面URL的方法小结
①. document.URL; http://localhost:81/Test/1.htm/id/12
②. document.location.href; http://localhost:81/Test/1.htm/id/12
③. self.location.href; http://localhost:81/Test/1.htm/id/12
④. document.location http://localhost:81/Test/1.htm/id/12
⑤. top.location.href; http://localhost:81/Test/1.htm/id/12
⑥. parent.document.location; http://localhost:81/Test/1.htm/id/12
⑦. top.location.hostname; localhost
⑧. location.hostname; localhost
⑨.window.location.protocol; http
①. window.location.host; localhost:81
②.window.location.pathname; /Test/1.htm/id/12
哪种代码获取的是url的哪部分内容是不是就一目了然了!!!!!