Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2007
    Location
    Wales
    Posts
    2,432
    Tokens
    141

    Latest Awards:

    Post CSS/Javascript Help

    Hey, I have another problem, this one more javascript. I have a script that allows users to drag and drop certain divs anywhere they like. However, when the page is refreshed, the position is reset to default. Does anyone know how I can make it save the position? Perhaps using cookies or something?

    +Rep for any help.

    Thank you.
    Free Online Games And Videos:
    http://www.vincesgames.com



  2. #2
    Join Date
    Mar 2008
    Location
    Swindon, UK
    Posts
    1,274
    Tokens
    187
    Habbo
    :Ltd

    Latest Awards:

    Default

    I wouldn't recommend cookies really. You need the locations to be saved somewhere, and then you will need to reposition them accordingly with the saved data.
    Hi, names James. I am a web developer.

  3. #3
    Join Date
    Jan 2007
    Location
    Wales
    Posts
    2,432
    Tokens
    141

    Latest Awards:

    Default

    Quote Originally Posted by Protege View Post
    I wouldn't recommend cookies really. You need the locations to be saved somewhere, and then you will need to reposition them accordingly with the saved data.
    Okay then, how would I do that? The current script I have:

    Code:
    <!--;
    var pickedUp = new Array("", false);
    function getReadyToMove(element, evt) {
    pickedUp[0] = element;
    pickedUp[1] = true;
    }
    
    function checkLoadedObjects(evt) {
      if (pickedUp[1] == true) {
      var currentSelection = document.getElementById(pickedUp[0]);
    
      currentSelection.style.position = "fixed";
      currentSelection.style.top = (evt.clientY + 1) + "px";
      currentSelection.style.left = (evt.clientX + 1) + "px";
      }
    }
    
    function dropLoadedObject(evt) {
      if (pickedUp[1] == true) {
      var currentSelection = document.getElementById(pickedUp[0]);
      currentSelection.style.position = "fixed";
      currentSelection.style.top = (evt.clientY + 1) + "px";
      currentSelection.style.left = (evt.clientX + 1) + "px";
      pickedUp = new Array("", false);
      }
    }
    
    //-->
    Free Online Games And Videos:
    http://www.vincesgames.com



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •