1, get the current full URL <script type= "text/javascript" > Thisurl = document. URL; Thishref = Document.location.href; Thissloc = Self.location.href; Thisdloc = document.location; Strwrite = "Thisurl: [" + Thisurl + "]<br/>" strwrite + = "Thishref: [" + Thishref + "]<br/>" strwrite + = " Thissloc: ["+ Thissloc +"]<br/> "strwrite + =" Thisdloc: ["+ Thisdloc +"]<br/> "document.write (strwrit e); </script>2. Get the current domain name information <script type= "text/javascript" >thistloc = top.location.href; Thisploc = parent.document.location; Thisthost = Top.location.hostname; Thishost = Location.hostname; Strwrite = "Thistloc: [" + Thistloc + "]<br/>" strwrite + = "Thisploc: [" + Thisploc + "]<br/>" Strwrite + = "Thisthost: [" + Thisthost + "]<br/>" strwrite + = "Thishost: [" + Thishost + "]<br/>" document.write (str Write); </script>3. Get the current page <script type= "Text/javascript" > tmphpage = Thishref.split ("/"); Thishpage = Tmphpage[tmphpage.length-1]; Tmpupage = Thisurl.split ("/"); Thisupage = Tmpupage[tmpupage.length-1]; Strwrite = "Thishpage: [" + Thishpage + "]<br/>" strwrite + = "Thisupage: [" + Thisupage + "]<br/>" documen T.write (Strwrite); </script>
JavaScript Gets the current path