title: How to save a highlighted html text for later use?
body: <p>I am trying to save the highlight text in a web page so that when the user logs back in, he gets the same highlighted text.</p>
  
  <p>My approach towards it as follows:</p>
  
  <p>1) get the <strong>offset and the node details</strong> from the selected text by using the <code>window.getSelection()</code> method.</p>
  
  <p>2) Save them in a database.</p>
  
  <p>3) Use the saved details and highlight the text again when the user logs back in.</p>
  
  <p>After research on other sites and stack exchange I found that I can dynamically highlight a text by creating a range object which requires node and offset no as its parameter as is seen in the following code.</p>
  
  <pre><code>               var range = document.createRange();
                 range.setStart(startNode, start_offset );  // node and offset are provided in parameters.
                 range.setEnd(endNode, end_offset );
  </code></pre>
  
  <p>Now, when user selects the text, I can extract the selected text's starting and ending offset by using the <code>window.getSelection()</code> method. But I could not extract the node details.</p>
  
  <blockquote>
    <p>Now I could not figure it out that how can I extract the node details
    and save it in a file or as a cookie so that I can highlight the same
    text again when the user opens the browser again.</p>
  </blockquote>
  
  <p>I tried to find out to my best in the internet and stack exchange but no site was giving the solution approach towards saving the node Information.</p>
  
  <p>Please help me to find a solution so that this work can be useful for other people as well.</p>
  
  <p>Thanks in advance.</p>