62,050
社区成员
发帖
与我相关
我的任务
分享
function getUrlParam(name){
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r!=null) return unescape(r[2]); return null;
}
如果aa.aspx?id=3
调用时只需getUrlParam("id")即可以得到3
<%@ page language="c#" runat="server" %>
<script language="c#" runat="server">
public string strtheurl;
public string ccid;
public void Page_Load(Object src, EventArgs e)
{
NameValueCollection ServerVariables = Request.ServerVariables;
ccid = Request.QueryString["uu"];
strtheurl = ServerVariables["URL"].ToString();
strtheurl = strtheurl.Substring(0, strtheurl.IndexOf("ly.aspx", 0, strtheurl.Length));
strtheurl = "http://" + ServerVariables["HTTP_HOST"].ToString() + strtheurl;
}
</script>
document.write("<script>var uid='<%=ccid%>';var url='<%=strtheurl%>';</script>")
<script>
String.prototype.getQuery = function(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = this.substr(this.indexOf("\?")+1).match(reg);
if (r != null) return unescape(r[2]);
return null;
}
var id=window.location.toString().getQuery('ID'); //获取id的值
alert(id);
</script>