JS获取当前页面路径的相关方法(属性)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title></title>
</head>
<body>
<table width=100% cellpadding=0 cellspacing=0 border=0 >
<script language="javascript">
thisURL = document.URL;
thisHREF = document.location.href;
thisSLoc = self.location.href;
thisDLoc = document.location;
strwrite = "<tr><td valign=top>thisURL: </td><td>[" + thisURL + "]</td></tr>"
strwrite += "<tr><td valign=top>thisHREF: </td><td>[" + thisHREF + "]</td></tr>"
strwrite += "<tr><td valign=top>thisSLoc: </td><td>[" + thisSLoc + "]</td></tr>"
strwrite += "<tr><td valign=top>thisDLoc: </td><td>[" + thisDLoc + "]</td></tr>"
document.write( strwrite );
</script>
<tr><td colspan="2">
thisDLoc = document.location; <br />
thisURL = document.URL;  <br />
thisHREF = document.location.href;  <br />
thisSLoc = self.location.href; <br />
</td></tr>
<script language="javascript">
thisTLoc = top.location.href;
thisPLoc = parent.document.location;
thisTHost = top.location.hostname;
thisHost = location.hostname;
strwrite = "<tr><td valign=top>thisTLoc: </td><td>[" + thisTLoc + "]</td></tr>"
strwrite += "<tr><td valign=top>thisPLoc: </td><td>[" + thisPLoc + "]</td></tr>"
strwrite += "<tr><td valign=top>thisTHost: </td><td>[" + thisTHost + "]</td></tr>"
strwrite += "<tr><td valign=top>thisHost: </td><td>[" + thisHost + "]</td></tr>"
document.write( strwrite );
</script>
<tr><td colspan="2">
thisTLoc = top.location.href;  <br />
thisPLoc = parent.document.location;  <br />
thisTHost = top.location.hostname;  <br />
thisHost = location.hostname; <br />
</td></tr>
<script language="javascript">
tmpHPage = thisHREF.split( "/" );
thisHPage = tmpHPage[ tmpHPage.length-1 ];
tmpUPage = thisURL.split( "/" );
thisUPage = tmpUPage[ tmpUPage.length-1 ];
strwrite = "<tr><td valign=top>thisHPage: </td><td>[" + thisHPage + "]</td></tr>"
strwrite += "<tr><td valign=top>thisUPage: </td><td>[" + thisUPage + "]</td></tr>"
document.write( strwrite );
</script>
</table>
</body>
</html>
posted @ 2011-02-22 16:04  流失的痕迹  阅读(2981)  评论(0编辑  收藏  举报