I'm trying to write a website that allows users to highlight some text (change background to yellow), and then the app will save this so that the next time he or she comes back to the page, it'll be yellow already (as if they never left).
This is kind of two questions in one:
I can get the text using
window.getSelection().toString()
, but I don't know how to get it as a selector so I can change the background of the selection to yellow.I don't know how to get the "address" of the selection. I need this so that I can save it to the database and colour it yellow the next time the user loads the page.
EDIT Currently looking into this: https://github.com/timdown/rangy