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

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

AngularJS通过$location获取及改变当前页面的URL

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

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

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

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

在asp.net中获取当前页面的URL的方法(推荐)

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

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

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

精品推荐
分类导航