przyklad zapamietujacy przewiniecie w cookie:
<html>
<head>
<script type="text/javascript">
function setCookie(name, val, exp, pth, dmn, scr) {
document.cookie = name + '=' + escape(val) +
(exp ? ';expires=' + e.toGMTString() : '') + (pth ? ';path=' + pth : '') +
(dmn ? ';domain=' + dmn : '') + (scr ? ';secure' : '');
}
function getCookie(name) {
var r = new RegExp('( |^)' + name + '=?([^;]*)(;|$)', ''), c;
return (c = document.cookie.match(r)) ? unescape(c[2]) : null;
}
function saveScroll() {
setCookie('scrollLeft', document.body.scrollLeft);
setCookie('scrollTop', document.body.scrollTop);
}
function loadScroll() {
scrollTo(getCookie('scrollLeft'), getCookie('scrollTop'));
}
</script>
</head>
<body onload="loadScroll()">
<table style="width: 200%; height: 200%">
<tbody><tr><td align="center" valign="middle">
<form action="?" method="post" onsubmit="saveScroll()">
<input type="submit" />
</form>
</td></tr></tbody>
</table>
</body>
</html>