页面操作postback后保持滚动条位置
2012-08-13 11:11
274 查看
Javascript添加如下语句即可: function fnLoad()
{
with(window.document.body)
{
addBehavior ("#default#userData"); // 使得body元素可以支持userdate
load("scrollState" + getFileName()); // 获取以前保存在userdate中的状态
scrollLeft = getAttribute("scrollLeft"); // 滚动条左位置
scrollTop = getAttribute("scrollTop");
}
}
function fnUnload()
{
with(window.document.body)
{
setAttribute("scrollLeft",scrollLeft);
setAttribute("scrollTop",scrollTop);
save("scrollState" + getFileName());
// 防止受其他文件的userdate数据影响,所以将文件名加上了
// userdate里的数据是不能跨目录访问的
}
}
window.onload = fnLoad;
window.onunload = fnUnload;
{
with(window.document.body)
{
addBehavior ("#default#userData"); // 使得body元素可以支持userdate
load("scrollState" + getFileName()); // 获取以前保存在userdate中的状态
scrollLeft = getAttribute("scrollLeft"); // 滚动条左位置
scrollTop = getAttribute("scrollTop");
}
}
function fnUnload()
{
with(window.document.body)
{
setAttribute("scrollLeft",scrollLeft);
setAttribute("scrollTop",scrollTop);
save("scrollState" + getFileName());
// 防止受其他文件的userdate数据影响,所以将文件名加上了
// userdate里的数据是不能跨目录访问的
}
}
window.onload = fnLoad;
window.onunload = fnUnload;
相关文章推荐
- 如何作到在页面POSTBACK刷新后,使LISTBOX的滚动条仍然保持上次的位置
- 当页面PostBacks的时候,保持滚动条的位置
- 如何在ASP.NET中PostBack后保持页面的位置(滚动条位置)
- 如何作到在页面POSTBACK刷新后,使LISTBOX的滚动条仍然保持上次的位置
- 如何做到在页面POSTBACK刷新后,使LISTBOX的滚动条仍然保持上次的位置
- ASP.NET 2.0 PostBack请求后保持页面滚动条的位置
- 页面回发(PostBack)后,滚动条位置保持不变
- ASP.NET 2.0PostBack后保持页面滚动条的位置
- 如何在ASP.NET中PostBack后保持页面的位置(滚动条位置)
- ASP.NET 2.0PostBack后保持页面滚动条的位置
- 页面刷新后滚动条保持原来位置,AutoPostBack=true后,保持页面焦点位置
- isPostBack后保持页面滚动条的位置
- 保持页面中滚动条的位置,使得页面提交后滚动条还是在原来的位置
- 提交页面后保持现在滚动条的位置(启用智能导航) (转载)
- sharepoint 2010 页面刷新时滚动条位置保持不变 Controlling scrollbar position on postback
- [转]用一个JS代码实现页面刷新后保持页面滚动条的位置
- 页面刷新后保持滚动条的原始位置
- Asp.net保持页面滚动条位置(页面提交后不变)
- sharepoint 2010 页面刷新时滚动条位置保持不变 Controlling scrollbar position on postback
- javaScript刷新页面—滚动条位置不变的操作