当前位置:Gxlcms > JavaScript > JS获取几种URL地址的方法小结_javascript技巧

JS获取几种URL地址的方法小结_javascript技巧

时间:2021-07-01 10:21:17 帮助过:12人阅读

以下为JS获取几种URL地址的方法
代码如下:

thisURL = document.URL;
thisHREF = document.location.href;
thisSLoc = self.location.href;
thisDLoc = document.location;

thisTLoc = top.location.href;
thisPLoc = parent.document.location;
thisTHost = top.location.hostname;
thisHost = location.hostname;

tmpHPage = thisHREF.split( "/" );
thisHPage = tmpHPage[ tmpHPage.length-1 ];
tmpUPage = thisURL.split( "/" );
thisUPage = tmpUPage[ tmpUPage.length-1 ];


下面为使用JS获取MAC地址、IP地址及主机名的方法:
代码如下: