Inserting selected text in grid view at cursor position in textbox

Inserting selected text in grid view at cursor position in textbox works fine in IE 7 but not in mozila / firefox

but
var objRange = document.selection.createRange(); var sOldRange = objRange.text;

I have tried window.selection and var range = ctrl.createTextRange();

still no effect.?
pls tell whts going wrong