js获取当前路径的简单示例代码
<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代码判断输入的字符串是否含有特殊字符和表情,通过js代码if语句进行判断,并结合自己开发的情景,具体操作步骤大家可查看下文的详细讲解,感兴趣的小伙伴们可以参考一下。2017-08-08用最简单的方法判断JavaScript中this的指向(推荐)
都说 JavaScript 是一种很灵活的语言,这其实也可以说它是一个混乱的语言,下面通过本文给大家分享JavaScript中this的指向知识,感兴趣的朋友一起看看吧2017-09-09
最新评论