Entry
How do I access the user's selection (highlighted text) in a document?
If you DO overwrite, how then do you access the entire changed source?
Apr 8th, 2000 04:25
Martin Honnen, John Marc,
NN4 has
var text = document.getSelection();
to read the selected text.
IE4+ has a sophisticated
document.selection
object which allows to create a range to manipulate the selection. If
you just want to read the selected text use
var text = document.selection.createRange().text;
If you for instance what to overwrite it use e.g.
document.selection.createRange().text = 'Kibology';
At the time of writing it seems that NN6 aims to at least provide
document.getSelection()
as NN4 does but it doesn't so far work in NN6PR1 preview release.