read id of html objects with cookies

39 views Asked by At

I wanna build a single-page layout but i have to use cookies to save the current position on the site because it 'has' to reload the page everytime you click on a link (task for school).

So what I wanted to do is reading the current position of the user (whenever he/she scrolls the page), send that position to a cookie. When the page is reloaded I want to let the user see his previous position and then automatically scroll (using jquery animation) to the position he just clicked on(position of link's anchor)

Can someone help me start building this?

1

There are 1 answers

2
Just code On
$("#myTextInput").bind("keydown keypress mousemove", function() {
  alert("Current position: " + $(this).caret().start);
});

get current position of the cursor

for animate to position http://api.jquery.com/animate/

Regards...:)

[updated]

use this.localName attribute so

 $("#myTextInput").bind("keydown keypress mousemove", function() {
      alert("Current position: " + $(this).caret().start);
    aler(this.localName);//this will be div which your is looking at currently
    });