I need a way to maintain moved div positions when the page reloads

Discussion in 'JavaScript' started by tmg, Jan 27, 2008.

  1. #1
    I have the following functions on my website and need a way to maintain the moved div positions when the user loads another page or reloads the current page. I have looked at various cookie codes available online and tried (without any luck) to adapt them. I am fairly new to javascript, but know just enough that I managed to piece together the functions below from various code snippets available online. Can anyone help, or point me in the right direction?

    Thanks in advance-
    Teri

    view test page here -
    http://www.artsitedesign.com/teri/bp_iceas3.cfm

    below is my moveObject funtion, the second function moves the divs back to their original position. Both are called with onClick.

    function moveObject(){
    var object=document.getElementById('todobox');
    object.style.position='absolute';
    object.style.top=0 + 'px';
    object.style.left=0 + 'px';
    var object=document.getElementById('contentbox');
    object.style.position='absolute';
    object.style.top=1 + 'px';
    object.style.left=400 + 'px';
    object.style.textAlign='left';
    }

    function MM_moveObject(){
    var object=document.getElementById('todobox');
    object.style.position='absolute';
    object.style.top=0 + 'px';
    object.style.left=-400 + 'px';
    var object=document.getElementById('contentbox');
    object.style.position='absolute';
    object.style.top=1 + 'px';
    object.style.left=0 + 'px';
    object.style.textAlign='center';
    }
    Thanks Edit/Delete Message
     
    tmg, Jan 27, 2008 IP
  2. ltdraper

    ltdraper Peon

    Messages:
    30
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Store the positions in <INPUT type="hidden"> variables. Update their values when you move the divs. Move the div to the hidden values wen the page loads.

    Or am I missing something in your question?
     
    ltdraper, Feb 1, 2008 IP