Winternet

Getting Selected Text from a Textarea Through Javascript in Safari

Filed under: — jwinter on 7/19/2005 at 2:22 pm

Is not possible. Will update this post if shown to be incorrect.

How it’s done in IE:

document.selection.createRange().text will contain your selected text.

How it’s done in Mozilla/Firefox:

//Get the textbox through the DOM
var txta = document.getElementById(’txt’);
//this will contain your selected text
txta.value.substring(txta.selectionStart, txta.selectionEnd));

How it’s done in Safari:

Call Dave Hyatt and ask him what’s selected.

0.056 || Powered by WordPress