1

How can I retain the user's text selection when calling $(inputElement).focus() on some text input element, inputElement, so that they can still use Ctrl+C after inputting some text top their initial selection?

I have considered intercepting the $(document).blur(...) event and preventing propagation to keep the selected text, but I'm not sure if it will work across all major browsers, if at all.

Petrus Theron
  • 27,855
  • 36
  • 153
  • 287

1 Answers1

0

if i didn't misunderstood...

you can use window.storage or document.cookie(in case window.storage is un available)... when the user input text in the field you can store its value(onBlur) against an id and on ctrl+C retrieve the value and put it else where (in case of ctrl+z)

Rafay
  • 30,950
  • 5
  • 68
  • 101
  • I already know which text the user selected. I just don't want to jar the user's expectations by automatically de-selecting their selection just because I want them to focus on an input field. They may have wanted to copy the selected text. I have looked at jQuery clipboard plugins, but none of them work reliably across browsers without Flash support. – Petrus Theron Feb 22 '11 at 10:47