In the popup window, selText does have the value "great," but the length is always undefined. Something related with the encoding of the string?
var selText = document.getSelection(); //suppose "great" is selected
alert( "selected ->" + selText + " len is " + selText.length);