国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

獲取當前url

2024-07-10 13:13:26
字體:
來源:轉載
供稿:網友
如: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<arr_param.length;i++){ 
var temp_str = new Array() 
temp_str=arr_param[i].split("=") 
var obj=new Object() 
obj.param_name=temp_str[0] 
obj.param_str=temp_str[1] 
arr_param[i]=obj 

for(var i=0;i<arr_param.length;i++){ 
document.write(arr_param[i].param_str); 


</script> 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 徐汇区| 宜君县| 枣庄市| 池州市| 比如县| 运城市| 临夏市| 永城市| 莱芜市| 思茅市| 桂平市| 万山特区| 浑源县| 海门市| 康平县| 克东县| 临高县| 林周县| 夹江县| 鲁山县| 万年县| 广丰县| 吉林市| 体育| 措勤县| 廊坊市| 方正县| 财经| 贺州市| 司法| 霍州市| 安国市| 花垣县| 安宁市| 安岳县| 内江市| 衢州市| 海晏县| 瑞金市| 吉木萨尔县| 赤水市|