ResolveClientUrl返回相对于当前页面下文件的地址
ResolveUrl则返回页面所在应用程序下的相对地址
在使用相对URL地址时一定要在前面加上(~)或(~/)
/// <summary> /// 获得根路径 /// </summary> /// <returns></returns> public static string GetRootPath() { string path = HttpContext.Current.Request.Url.AbsoluteUri; path = path.Substring(0, path.IndexOf(HttpContext.Current.Request.Url.LocalPath)); path += HttpContext.Current.Request.ApplicationPath; if (!path.EndsWith("/")) { path += "/"; } return path; } /// <summary> /// 获得物理根路径 /// </summary> /// <returns></returns> public static string GetRootServerPath() { string path = HttpContext.Current.Server.MapPath("~"); if (!path.EndsWith("\\")) { path += "\\"; } return path; }
function GetUrlParas(paras) { var url = location.href; var paraString = url.substring(url.indexOf("?") + 1, url.length).split("&"); var paraObj = {} for (i = 0; j = paraString[i]; i++) { paraObj[j.substring(0, j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=") + 1, j.length); } var returnValue = paraObj[paras.toLowerCase()]; if (typeof (returnValue) == "undefined") { return ""; } else { return returnValue; } } //GetPara function GetParasByUrl(url,paras) { if (url.indexOf("?") < 0 ) { return ""; } var paraString = url.substring(urls.indexOf("?") + 1, url.length).split("&"); var paraObj = {} for (i = 0; j = paraString[i]; i++) { paraObj[j.substring(0, j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=") + 1, j.length); } var returnValue = paraObj[paras.toLowerCase()]; if (typeof (returnValue) == "undefined") { return ""; } else { return returnValue; } } function GetRootPath() { var urlPart = window.location.href; var filePart = window.location.pathname; var paraPart = window.location.search; var retV = urlPart.replace(filePart, "").replace(paraPart, ""); return retV; } //function-end