js实现页面刷新滚动条位置不变
今天因为这个问题困扰了很久网上的例子都尝试没效果,后来发现一点原来是内容最外层没有div的原因
<%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="SpotChkDetail.aspx.cs"Inherits="Topevery.DUM.Web.Observer.SpotChkDetail"%>
<scriptrunat="server">
protectedoverrideboolHeaderScriptFilter(Topevery.Framework.Web.Configuration.Scriptval)
{
switch(val.Key)
{
case"ajaxpro2.prototype":
case"ajaxpro2.core":
case"ajaxpro2.converter":
case"ajaxpro2.onloading":
case"ajaxpro2.assembly.AjaxFunction":
case"my97":
case"image":
case"jquery.pagination":
case"jquery.jqGrid.locale":
case"jquery.jqGrid":
case"jquery-load-image":
case"jquery.validationEngine":
case"jquery.validationEngine-zh":
case"WeiBo":
case"jquery.mousewheel":
case"jquery.iviewer":
case"jquery.gallery.singer":
returntrue;
default:
returnbase.HeaderScriptFilter(val);
}
}
protectedoverrideboolHeaderStyleFilter(Topevery.Framework.Web.Configuration.Styleval)
{
switch(val.Key)
{
case"jqgrid":
case"jqgrid-grey":
case"validationEngine":
returntrue;
default:
returnbase.HeaderStyleFilter(val);
}
}
</script>
<!DOCTYPEhtml>
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>
<title></title>
</head>
<bodyid="bbdy">
<formid="form1"runat="server">
<div>
<divclass="TUI-layout-north">
<divclass="TUI-title">
<spanclass="TUI-icoico-note"></span><strong>抽查</strong>
</div>
<divclass=""style="float:right;margin-top:-30px;z-index:99999;position:relative;">
<objectid="WebBrowser"classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"height="0"width="0">
</object>
<inputtype="button"class="TUI-button"value="打印"onclick="document.all.WebBrowser.ExecWB(6,1)"id="Button2"/>
<inputtype="button"class="TUI-button"value="打印预览"onclick="document.all.WebBrowser.ExecWB(7,1)"/>
</div>
<divclass="TUI-alert">
<spanclass="ml10px">抽查时间:<asp:LabelID="lbBeginDate"runat="server"Text="Label"></asp:Label>
失效时间:<asp:LabelID="lbEndDate"runat="server"Text="Label"></asp:Label>
消息内容:<asp:LabelID="lbContent"runat="server"Text="Label"></asp:Label></span>
<divstyle="display:none">
<asp:ButtonID="btnRef"runat="server"OnClick="btnRef_Click"Text="刷新"/>
</div>
</div>
</div>
<divclass="TUI-layout-center">
<divclass="TUI-contentTUI-h100TUI-of-autoTUI-align-center">
<asp:RepeaterID="Repeater1"runat="server"OnItemDataBound="Repeater1_ItemDataBound">
<%--OnItemCommand="Repeater1_ItemCommand"--%>
<HeaderTemplate>
<tableclass="TUI-grid-listw100"id="observers">
<tr>
<thstyle="width:150px">巡查员头像
</th>
<thstyle="width:80px">姓名
</th>
<thstyle="width:120px">是否超时
</th>
<%--<thstyle="width:110px">城管通号码
</th>
<thstyle="width:110px">城管通版本
</th>--%>
<thstyle="width:100px">消息状态
</th>
<thstyle="width:100px">审核状态
</th>
<thstyle="width:150px">审核
</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<trclass="people_title_td">
<tdrowspan="2"valign="middle"style="width:110px">
<imgid="img_observer_poto"runat="server"height="135"style="border:1pxsolid#bababa;"width="100"/>
</td>
<tdstyle="width:60px">
<%#Eval("c_name")%>
<asp:HiddenFieldID="hfObId"runat="server"Value='<%#Eval("c_ob_id")%>'/>
<asp:HiddenFieldID="hfId"runat="server"Value='<%#Eval("c_id")%>'/>
</td>
<tdstyle="width:100px">
<%#Eval("c_is_over_time")%>
</td>
<%--<tdstyle="width:110px">
<%#Eval("c_pda_number")%>
</td>
<tdstyle="width:110px">
<%#Eval("c_pda_version")%>
</td>--%>
<tdstyle="width:90px">
<%#Eval("notify_state")%>
</td>
<tdstyle="width:90px">
<%#Eval("eligible_state")%>
</td>
<tdstyle="width:150px;">
<divstyle="display:<%#Eval("c_is_eligible").ToString()!="0"?"none":""%>">
<%--<asp:LinkButtonID="LinkButton1"runat="server"CommandName="lnk_poto"CommandArgument='<%#Eval("c_id")%>'>重摄</asp:LinkButton>
<asp:LinkButtonID="LinkButton2"runat="server"CommandName="lnk_ok"CommandArgument='<%#Eval("c_id")%>'>合格</asp:LinkButton>
<asp:LinkButtonID="LinkButton3"runat="server"CommandName="lnk_no"CommandArgument='<%#Eval("c_id")%>'>不合格</asp:LinkButton>--%>
<ahref='#'onclick='review(<%#Eval("c_id")%>,0,"重摄")'class='TUI-toolbar-btn'><span></span>重摄</a>
<ahref='#'id="qualified"onclick='review(<%#Eval("c_id")%>,1,"合格")'class='TUI-toolbar-btn'><span></span>合格</a>
<ahref='#'id="Unqualified"onclick='review(<%#Eval("c_id")%>,2,"不合格")'class='TUI-toolbar-btn'><span></span>不合格</a>
</div>
</td>
</tr>
<trclass="alt_tr2">
<tdcolspan="5"style="height:160px;text-align:left">
<tableclass="choucha-table">
<tr>
<asp:RepeaterID="rptImg"runat="server">
<ItemTemplate>
<td>
<divclass="div_imgTUI-notelist-containerTUI-gallerychoucha-img">
<divid='imge'+'<%#Eval("FileId")%>'>
<divclass="TUI-gallery-contentTUI-gallery-img">
<atitle='点击放大'href="javascript:void(0)"
sourceSrc='<%#Eval("Imageurl")%>'largeSrc='<%#Eval("Imageurl")%>'><imgsrc='<%#Eval("Imagethumbil")%>'/><span><%#Eval("Summary")%></span></a>
</div>
</div>
</div>
</td>
</ItemTemplate>
</asp:Repeater>
</tr>
</table>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
<inputtype="hidden"id="hdnvalue"runat="server"value="0"/><!----存放scorllTop值-->
</div>
</div>
</div>
<scripttype="text/javascript">
$(document).ready(function(){
TUILayout("form");
//LoadImage();
$(".div_img").gallery({
gallerySize:{width:90,height:120},
fullView:"true"//ture为允许点击图像全屏浏览
});
});
functionLoadImage(){
varjq_o_list=$("#observersdiv[@ref_id]");
for(vari=0;i<jq_o_list.length;i++){
load_to(jq_o_list[i]);
}
}
functionload_to(obj){
varjq_o=$(obj);
Topevery.DUM.Web.AjaxFunction.GetEvtDefault(jq_o.attr("ref_id"),function(ajaxResult){
varval=ajaxResult.value;
jq_o.empty();
jq_o.append(val.Html);
});
}
//$("#div_evt_img").gallery({
//images:evt_img_list,
//thumbSize:{width:65,height:60},//缩略图大小
//gallerySize:{width:380,height:280},//画廊图(中间大图)大小
//thumbDisplayNum:4,//缩略图显示数量
//scalingSize:{width:360,height:260},//画廊图(中间大图)自动比例缩放最大大小
//fullView:"true"//ture为允许点击图像全屏浏览
//});
functionReminder(){
NotSelectEvt("已经再次发送消息通知巡查员!");
}
functionreview(id,type,content){
if(confirmL("确认"+content+"吗?",function(){
Topevery.DUM.Web.AjaxFunction.ReviewImg(id,type);
$("#btnRef").click();
})){
}
}
</script>
</form>
</body>
</html>
<scripttype="text/javascript">
window.onbeforeunload=function(){
varscrollPos;
if(typeofwindow.pageYOffset!='undefined'){
scrollPos=window.pageYOffset;
}
elseif(typeofdocument.compatMode!='undefined'&&
document.compatMode!='BackCompat'){
scrollPos=document.documentElement.scrollTop;
}
elseif(typeofdocument.body!='undefined'){
scrollPos=document.body.scrollTop;
}
document.cookie="scrollTop="+scrollPos;//存储滚动条位置到cookies中
}
window.onload=function(){
if(document.cookie.match(/scrollTop=([^;]+)(;|$)/)!=null){
vararr=document.cookie.match(/scrollTop=([^;]+)(;|$)/);//cookies中不为空,则读取滚动条位置
document.documentElement.scrollTop=parseInt(arr[1]);
document.body.scrollTop=parseInt(arr[1]);
}
}
</script>
以上就是本文的全部内容,希望对大家有所帮助,同时也希望多多支持毛票票!