Sg2.9
find selected text
Recent RSS
find selected text
From:  alex
Date:  24. March 2012, 01:34

I need help finding info about the selected text.

I tried this, but it it came up undefined.

var selectedItems = document.getItems({
selected: true
});

var range = selectedItems.characters;

any help is greatly appreciated

Re: find selected text
From:  pqbd
Date:  25. March 2012, 23:50

The property you're looking for is the selectedRange of a TextStory object. This returns a TextRange object, which contains the whole string as the .content property, and an array of characters which each have a single character as their content.

var sel=document.selectedItems[0];
var range=sel.selectedRange;
console.log("this is the selected string:");
console.log(range.content);
console.log("this is the first selected character:");
console.log(range.characters[0].content);

Scripts
08.08.14, 15:24
15.05.14, 14:23
02.03.14, 19:16
18.11.13, 14:48
22.03.13, 03:05
22.02.13, 15:45
Posts
10.01.17, 16:37
19.02.16, 06:03
19.02.16, 06:00
17.01.16, 11:00
12.01.16, 13:10
25.11.15, 08:19
Script of the Moment
L-System 26.10.11