If you get the "current" domain name
host = Window.location.host;
Url=document.domain;
url = window.location.href;
Get the full URL path: The following code can be used to fully research the results:
<table width=100% cellpadding=0 cellspacing=0 border=0 >
<script>
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>
Thisdloc = document.location; <BR>
Thisurl = document. URL; <BR>
Thishref = Document.location.href; <BR>
Thissloc = self.location.href;<br>
<script>
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>
Thistloc = Top.location.href; <BR>
Thisploc = parent.document.location; <BR>
Thisthost = Top.location.hostname; <BR>
Thishost = location.hostname;<br>
<script>
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><tr><td>
Run as follows: 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;
Thisurl: [http://925bb.taobao.com/js/js%E8%8E%B7%E5%8F%96url.html]
Thishref: [http://925bb.taobao.com/js/js%E8%8E%B7%E5%8F%96url.html]
Thissloc: [http://925bb.taobao.com/js/js%E8%8E%B7%E5%8F%96url.html]
Thisdloc: [http://925bb.taobao.com/js/js%E8%8E%B7%E5%8F%96url.html]
Thistloc: [http://925bb.taobao.com/js/js%E8%8E%B7%E5%8F%96url.html]
Thisploc: [http://925bb.taobao.com/js/js%E8%8E%B7%E5%8F%96url.html]
Thisthost: [925bb.taobao.com]
Thishost: [925bb.taobao.com]
Thishpage: [js%e8%8e%b7%e5%8f%96url.html]
Thisupage: [js%e8%8e%b7%e5%8f%96url.html]
JS gets the URL of the current page