如: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值
刚写的一个小实例.实际中使用还是蛮多的.
获取当前url
2021-05-18 21:10:03Copyright © 1999-2025 中企动力科技股份有限公司(300.cn)All Rights Reserved
京公网安备11030102010293号 京ICP证010249-2
代理域名注册服务机构:中网瑞吉思(天津)科技有限公司 北京新网数码信息技术有限公司
域名投诉处理400-660-5555-9 service4006@300.cn
-
7 x 24全国售后支持
-
100 倍故障时长赔付
-
26 年26年行业服务经验
-
70 家全国售后支持
-
1600+ 名超千人的设计、研发团队
-
150 万服务企业客户150万家
我们尽快联系您