Unique element ID to reference later

Posted by Hanpan on Stack Overflow See other posts from Stack Overflow or by Hanpan
Published on 2010-03-24T09:00:14Z Indexed on 2010/03/24 9:03 UTC
Read the original article Hit count: 299

Filed under:

I'm trying to figure out a method of storing a unique reference to each tag on a particular page. I won't have any ability to edit the page content and I'll the generated UID to stay the same on every page refresh.

Since browsers don't generate any kind of UID for elements, I was thinking that the only method to do this would be to execute a script which walks the DOM and creates a UID for each it comes across. I don't know how accurate this will be, especially considering I'll need to ensure it creates the same UID for the tag each time the script crawls the page.

Can anyone think of any other, more accurate ways of mapping a page?

Many thanks.

© Stack Overflow or respective owner

Related posts about JavaScript