title: Javascript-Android get selected text script
body: <p>I tried to get selected text from an html page on each touchend event in android device but am not able to get selected text.</p>
  
  <p>Javascript code is : </p>
  
  <pre><code>if(window.getSelection)
  {
      t = window.getSelection();
  }
  else if(document.getSelection)
  {
      t = document.getSelection();
  }
  else if(document.selection)
  {
      t = document.selection.createRange().text;
  }
  </code></pre>
  
  <p>Thanks in Advance.</p>