|
1.方法document.URL(注意大小寫(xiě))
結(jié)果是:http://localhost/newurl/WebForm1.ASPx
2.HttpContext.Current.Request.Url.ToString(),
結(jié)果:http://localhost/newurl/WebForm1.ASPx
3.HttpContext.Current.Request.Url.PathAndQuery;
結(jié)果:/newurl/WebForm1.ASPx
備注:
如果當(dāng)前URL為
http://localhost/search.ASPx?user=tinyfool&tag=%BC%BC%CA%F5
通過(guò)HttpContext.Current.Request.Url.ToString()獲取到的卻是
http://localhost/search.ASPx?user=tinyfool&tag=¼¼Êõ
這顯然不對(duì),怎么辦?用HttpContext.Current.Request.Url.PathAndQuery好了,這個(gè)得到的正確的。:)
4.Javascript取url值
剛寫(xiě)的一個(gè)小實(shí)例.實(shí)際中使用還是蠻多的.