js获取当前地址JS获取当前URL的示例代码_javascript技巧
2020-11-27 21:20:17
责编:小采
代码如下:
thisURL = document.URL;
thisHREF = document.location.href;
thisSLoc = self.location.href;
thisDLoc = document.location;
strwrite = "| thisURL: | [" + thisURL + "] |
"
strwrite += "| thisHREF: | [" + thisHREF + "] |
"
strwrite += "| thisSLoc: | [" + thisSLoc + "] |
"
strwrite += "| thisDLoc: | [" + thisDLoc + "] |
"
document.write( strwrite );
script>
thisDLoc = document.location;
thisURL = document.URL;
thisHREF = document.location.href;
thisSLoc = self.location.href;
thisTLoc = top.location.href;
thisPLoc = parent.document.location;
thisTHost = top.location.hostname;
thisHost = location.hostname;
strwrite = "| thisTLoc: | [" + thisTLoc + "] |
"
strwrite += "| thisPLoc: | [" + thisPLoc + "] |
"
strwrite += "| thisTHost: | [" + thisTHost + "] |
"
strwrite += "| thisHost: | [" + thisHost + "] |
"
document.write( strwrite );
script>
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 ];
strwrite = "| thisHPage: | [" + thisHPage + "] |
"
strwrite += "| thisUPage: | [" + thisUPage + "] |
"
document.write( strwrite );
script>
下载本文
显示全文
|