手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >js获取当前路径的简单示例代码
js获取当前路径的简单示例代码
摘要: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()

【js获取当前路径的简单示例代码】相关文章:

父窗口获取弹出子窗口文本框的值

超酷右下浮出广告窗口代码

javascript实现简单的省市区三级联动

Javascript随机显示图片的源代码

angular2使用简单介绍

免费空间广告万能消除代码

鼠标图片振动代码

javascript获取select值的方法分析

js兼容火狐获取图片宽和高的方法

js获取滚动距离的方法

精品推荐
分类导航