I can't think of a good use case for it, but


I learned, yesterday, that it’s possible to get the value of highlighted text.

When was that implemented? I can’t think of a reason to use it, but I think it’s pretty cool. :rofl:

function alertme(){
var textarea = document.getElementById("textArea");  
var selection = (textarea.value).substring(textarea.selectionStart,textarea.selectionEnd);
alert (selection);
<p><textarea class="noscrollbars" id="textArea"></textarea></p>
<button onclick="alertme()">Click me</button>

Type something in the textarea, highlight only part of it, and click the button. Works in FF, IE, and Edge.


^ _ ^


Clipboard manipulation. Context specific search-and-replace. There’s a couple of uses out there.


Clipboard manipulation?? You can programmatically interfere with a systems clipboard???


^ _ ^




Medium also has a “top highlight” feature which shows the text that was most often highlighted when reading a specific article.


Kinda slick. AND, I’m glad that it can’t be arbitrary - according to the article, the user actually has to take action for it to work. I was worried that any code could copy a selection without the user’s knowledge.

Thank you.


^ _ ^


Well, you can get the contents of the users clipboard but most browsers will ask you to permit this first.