手机
当前位置:查字典教程网 >编程开发 >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】相关文章:

WordPress获取当前页面URL地址的方法

C#获取当前页面的URL示例代码

js和php如何获取当前url的内容

Yii获取当前url和域名的方法

js获取当前地址 JS获取当前URL的示例代码

PHP获取当前页面URL函数实例

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

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

asp获取当前URL代码

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

精品推荐
分类导航