页面滚动位置保持

步骤一

replace the tag of <body> with the follewing codes:

<%
  if (Request["__SCROLLPOS"] != null &&
      Request["__SCROLLPOS"] != String.Empty) { 
      int pos = Convert.ToInt32 (Request["__SCROLLPOS"]); 
      Response.Write ("<body id=\"theBody\" " +
          "onscroll=\"javascript:document.forms[0].__SCROLLPOS.value = " + 
          "theBody.scrollTop;\" " + 
          "onload=\"javascript:theBody.scrollTop=" + pos + ";\">"); 
  }
  else {
      Response.Write ("<body id=\"theBody\" " + 
          "onscroll=\"javascript:document.forms[0].__SCROLLPOS.value =" + 
          "theBody.scrollTop;\">");
  }
%>

步骤二

add the follewing codes between <form> and </form>

<input type="hidden" name="__SCROLLPOS" value="" /> 

posted on 2005-09-13 17:02  jinchun  阅读(295)  评论(0编辑  收藏  举报