js获取当前路径的简单示例代码
js获取当前路径的简单示例代码
发布时间:2016-12-30 来源:查字典编辑
摘要:thisURL=document.URL;thisHREF=document.location.href;thisSLoc=self.loc...

<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( strwrite );

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 );

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 );

var url="<%=request.getRequestURI()%>";

alert(url)

</script>

request.getRequestURI();

request.getRequestURL();

request.getQueryString();

request.getServletPath()

可以得到自己的网络地址:request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getRequestURI()

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新Javascript教程学习
热门Javascript教程学习
编程开发子分类