首页 > 代码库 > javascript获取当前路径
javascript获取当前路径
1、获取当前完整网址<script type="text/javascript"> thisURL = document.URL; thisHREF = http://www.mamicode.com/document.location.href; " thisURL: [" + thisURL + "]<br />" strwrite += " thisHREF: [" + thisHREF + "]<br />" strwrite += " thisSLoc: [" + thisSLoc + "]<br />" strwrite += " thisDLoc: [" + thisDLoc + "]<br />" document.write( strwrite ); </script>2.获取当前域名信息<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( strwrite ); </script>3.获取当前页面<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 />" document.write( strwrite ); </script>
javascript获取当前路径
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。