function SetCookie(sName, sValue) {
document.cookie = sName + "=" + escape(sValue);
}
function GetCookie(sName) {
var aCookie = document.cookie.split(";");
for (var i = 0; i < aCookie.length; i++) {
var aCrumb = aCookie[i].split("=");
if (sName == aCrumb[0]) {
return unescape(aCrumb[1]);
}
}
return null;
}
function scrollback() {
if (GetCookie("scroll") != null) {
document.body.scrollTop = GetCookie("scroll");
}
}
使用:οnscrοll="SetCookie('scroll', body.scrollTop);" οnlοad="scrollback();"
js 记住浏览器的滚动条位置
最新推荐文章于 2024-06-17 11:34:59 发布