获取当前url
时间:2024-05-09 09:04:30
如: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值
刚写的一个小实例.实际中使用还是蛮多的.
<script language=javascript> var str_url,str_pos,str_para; var arr_param=new Array(); str_url = window.location.href; str_pos = str_url.indexOf("?"); str_para = str_url.substring(str_pos+1); if (str_pos>0){ arr_param=str_para.split("&"); for(var i=0;i
标签:获取当前url
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
php中关于socket的系列函数总结
2023-11-17 13:57:35
在python代码中加入环境变量的语句操作
2023-03-01 22:58:19
![](https://img.aspxhome.com/file/2023/0/97050_0s.jpg)
Golang实现的聊天程序服务端和客户端代码分享
2024-05-09 14:54:58
如何用拦截表单的方法上传图片?
2010-06-16 09:50:00
如何使用MyBatis Plus实现数据库curd操作
2024-01-21 17:37:13
![](https://img.aspxhome.com/file/2023/9/99919_0s.png)
Python AES加密模块用法分析
2021-05-29 05:13:58
python使用reportlab生成pdf实例
2022-09-13 09:36:42
![](https://img.aspxhome.com/file/2023/3/105033_0s.png)
调试PHP程序的多种方法介绍
2024-06-05 09:48:51
基于Python实现微信自动回复功能
2021-10-17 14:01:54
![](https://img.aspxhome.com/file/2023/7/131657_0s.png)
关于自动化测试框架pytest的Fixture固件
2023-10-16 00:02:50
![](https://img.aspxhome.com/file/2023/9/97539_0s.png)
SpringBoot图文并茂详解如何引入mybatis与连接Mysql数据库
2024-01-25 15:07:32
![](https://img.aspxhome.com/file/2023/3/129293_0s.png)
Python制作微信好友背景墙教程(附完整代码)
2022-11-13 08:31:08
![](https://img.aspxhome.com/file/2023/3/114993_0s.jpg)
python库-dotenv包 及 .env配置文件详解
2023-09-08 20:22:38
npm qs模块使用详解
2024-04-25 13:11:14
详解Django模板层过滤器和继承的问题
2023-02-08 06:28:04
![](https://img.aspxhome.com/file/2023/0/79400_0s.png)
在tensorflow以及keras安装目录查询操作(windows下)
2023-10-31 10:49:21
![](https://img.aspxhome.com/file/2023/3/86463_0s.jpg)
Python实现邮件自动下载的示例详解
2023-06-15 04:44:35
![](https://img.aspxhome.com/file/2023/2/123792_0s.png)
如何在网页中制作虚线表格
2010-10-20 20:07:00
Python3网络爬虫开发实战之极验滑动验证码的识别
2022-10-02 22:06:14
![](https://img.aspxhome.com/file/2023/1/85221_0s.jpg)
python中图像通道分离与合并实例
2021-04-02 00:09:48