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:

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

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

V/r,

^ _ ^

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???

V/r,

^ _ ^

Yeah.

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.

V/r,

^ _ ^

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

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.