mystat.aspx页的内容如下:<%@ page language="c#" runat="server" %>
<script language="c#" runat="server">
public string strStyle;
public string strtheurl;
public void Page_Load(Object src,EventArgs e)
{
NameValueCollection ServerVariables = Request.ServerVariables;
strStyle=Request.QueryString["style"];
strtheurl=ServerVariables["URL"].ToString();
strtheurl=strtheurl.Substring(0,strtheurl.IndexOf("mystat.aspx",0,strtheurl.Length));
strtheurl="http://"+ServerVariables["HTTP_HOST"].ToString()+strtheurl;

}
</script>
document.write("<script>var style='<%=strStyle%>';var url='<%=strtheurl%>';</script>")
_dwrite("<script language=javascript src="+url+"stat.aspx?style="+style+"&referer="+escape(top.document.referrer)+"&screenwidth="+(screen.width)+"></script>");
function _dwrite(string) {document.write(string);}a.aspx页里有如相调用代码:
<script src="http://localhost/test/mystat.asp?style=icon"></script> 现在执行a.aspx 页,为什么在stat.aspx页里,用Request.QueryString["referer"]取到的网址是http://localhost/test/mystat.asp ?
要如何才能取到a.aspx这个网址呢?

解决方案 »

  1.   

    window.location.href可以得到地址
    document.location.search;可以获得所有querystring
    单个querystring可以用如下方法
    http://www.aspxboy.com/private/showthread.asp?threadid=254
      

  2.   

    ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.2052/cpref/html/frlrfSystemWebHttpRequestClassUrlReferrerTopic.htmMSDN
      

  3.   

    document.write("<script>var style='<%=strStyle%>';var url='<%=strtheurl%>';</script>")
    _dwrite("<script language=javascript src="+url+"stat.aspx?style="+style+"&referer="+escape(top.document.referrer)+"&screenwidth="+(screen.width)+"></script>");
    function _dwrite(string) {document.write(string);}为什么不会执行stat.aspx这个页?