Window getSelection() method
Window Object
Definition and Usage
The getSelection() method represents the text range selected by the user or the current position of the cursor.
Syntax
window.getSelection();
Browser support





All major browsers support the focus() method
Example
Example
Read the selected content:
function
foo
(
)
{
let
selObj
=
window
.
getSelection
(
)
;
alert
(
selObj
.
toString
(
)
)
;
}
Try it »
Window Object