[asp.net] 获取网页访问来路的几种方法

一、C#代码一

  string url = Request["referer"];
  Response.Write("alert('" url "')");
  Response.End();

 

可以使用如下的四种中的其中一种

  HttpRequest.UrlReferrer 
  Request.UrlReferrer.AbsolutePath
  HttpContext.Current.Request.Url.ToString()
  Request.ServerVariables["Http_Referer"]

 

获得上个页面链接地址

 

  二、HTML code

   <script >
   var url = 'js.aspx?referer=' encodeURIComponent(document.referrer);
   document.write(' <' 'script type="text/java script" src="' url '" > <' '/script >');
   </script >

 

  三、xmlhttp代码

  var objXMLHTTP=new ActiveXObject( "MICROSOFT.XMLHTTP "); 
  var url = "http://www.dzwebs.net/ " "se.asp?temp= " name1.value " &id= " name2.value " &len=   " name3.value;

  objXMLHTTP.open( "GET ",url,false);
  objXMLHTTP.send();
  var strReturn=objXMLHTTP.ResponseText;
  if (strReturn== "error ")
   {alert( "there is error occurred! ");

  else
  //do next


posted @ 2012-03-08 12:27  ishibin  阅读(2186)  评论(0编辑  收藏  举报