手机
当前位置:查字典教程网 >编程开发 >asp.net教程 >获取当前url
获取当前url
摘要:如:http://localhost/newurl/WebForm1.aspx1.方法document.URL(注意大小写)结果是:http...

如:http://localhost/newurl/WebForm1.aspx

1.方法document.URL(注意大小写)

结果是:http://localhost/newurl/WebForm1.aspx

2.HttpContext.Current.Request.Url.ToString(),

结果:http://localhost/newurl/WebForm1.aspx

3.HttpContext.Current.Request.Url.PathAndQuery;

结果:/newurl/WebForm1.aspx

备注:

如果当前URL为

http://localhost/search.aspx?user=tinyfool&tag=%BC%BC%CA%F5

通过HttpContext.Current.Request.Url.ToString()获取到的却是

http://localhost/search.aspx?user=tinyfool&tag=¼¼Êõ

这显然不对,怎么办?用HttpContext.Current.Request.Url.PathAndQuery好了,这个得到的正确的。:)

4.Javascript取url值

刚写的一个小实例.实际中使用还是蛮多的.

[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]

【获取当前url】相关文章:

多种语言下获取当前页完整URL及其参数

DedeCms获取当前页面URL地址的实现方法

解析js如何获取当前url中的参数值并复制给input

asp.net获取当前网址url的各种属性(文件名、参数、域名 等)的代码

使用PHP获取当前url路径的函数以及服务器变量

php获取当前网址url并替换参数或网址的方法

js获取或设置当前窗口url参数的小例子

dedecms获取文档当前栏目所在目录链接URL

获取当前网页document.url location.href区别总结

PHP获取当前url的具体方法全面解析

精品推荐
分类导航