|
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值
剛寫的一個小實例.實際中使用還是蠻多的.