I trying to do:
// Create cookie to store scrolled position
function scrollPos()
{
for ( var i=0; i<divIds.length; i++ ) {
divId = divIds[i];
var strCook = document.cookie;
if(strCook !=0)
{
var strPos = strCook.substring(+2);
document.getElementById(divId).scrollTop = strPos;
}...
ok, so I think I need to get the cookie value from the previous state and add the other values to the cookie.
Then be able to read back the two values independently, is this the right way to go about this or would it be better to use separate cookies for each value?
/me is lost
Trying to get cookie values stored for each divId using:
function scrollPos()
{
for ( var i=0; i<divIds.length; i++ ) {
divId = divIds[i];
var strCook = document.cookie;
if(strCook.indexOf("!~")!=0)
{
var intS = strCook.indexOf("!~");
var intE = strCook.indexOf("~!");
var strPos =...
I see, I had tried to incorporate the onResize event into the original loop with no sucess, I think that I have a better understanding of how for loops can be used.
Thanks alot
I find this line rather complex in terms of what it does:
var n=(/\d$/.test(divId))?divId.substr(divId.length-1):"";
I would like to say I understand how that works, but it's a bit beyond me, I can see how it's taking the divId.length - 1 and creating a variable 'n', but I do not get the...
Thanks tsuji, that has fixed the scrolling problem. Any idea how to fix the other issues? I don't understand why one scrollbar-padder div resizes and the other does not...? I guess it may have something to do with how getElementById works.
I have built a test page so you can see the problems:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<style>
html {
overflow:hidden;
height:100%}
body{
width:100%;
font:12px arial;
margin:0px...
Ok let me clarify:
The onLoad event now works for both divs.
The onResize event works for the second div but not the first.
The setDivPosition function now sets both divs to the value of the second on refresh.
The scrollUp / scrollDown functions only work for the second div.
The div...
I have a script which resizes a div depending on the viewport size, allows the div to scroll using a custom scrollbar with up / down buttons and writes to a cookie to remember it's scrolled position on refresh.
I have grasped the concept of arrays and how they could be used to loop through...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.