opensubscriber
   Find in this group all groups
 
Unknown more information…

w : webkitsdk-dev@lists.apple.com 16 January 2006 • 3:54AM -0500

How do you select all text in contentEditable elements via JS?
by Todd Ditchendorf

REPLY TO AUTHOR
 
REPLY TO GROUP




Dear list,

I've got an element with contenteditable="true"

and I would like to do something like the following:

editableNode.focus();
editableNode.selectAll();

I'm having serious difficulty figuring out how to select all text of  
an editable element like this... the above method does not actually  
exist.

I've explored a lot of options... all have been dead ends.

Tried using the DOM2 Range object created by document.createTextRange
() method and its selectNodeContents() method... but this doesn't  
seem to actually control highlighting on the screen (please correct  
me if I'm wrong)

It looks like safari does not support the IE TextRange object  
returned by document.body.createRange() (again, correct me if I'm  
wrong) or else I could try calling execCommand("SelectAll") on the  
TextRange object.

I see that you _can_ call execCommand("SelectAll") on the document  
object... but i don't see anyway way to associate this with just a  
specific node or text range.

Can anyone please post and example of how you achieve this effect?

THANKS!

Todd Ditchendorf
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webkitsdk-dev mailing list      (Webkitsdk-dev@list...)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webkitsdk-dev/subscriber%40opensubscriber.com

This email sent to subscriber@open...

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.