[webkit-dev] programmatic text selection

Giacomo Luca Maioli luca at tricheco.net
Fri May 26 11:14:49 PDT 2006


> Folks, I've been all over the net without finding a definitive answer,
> so I thought I'd come to the source.  Is there any way, in
> Safari/webkit, to programmatically select some text in javascript?
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at opendarwin.org
> http://www.opendarwin.org/mailman/listinfo/webkit-dev
>

Yes, of course. You should use the "document.execCommand(few args)"   
command.
I successfully tested the 'SelectAll", "Copy", "Unselect" arguments  
in my dashboard widget. It works with text range too.

More info on Msdn pages:
http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/ 
execcommand.asp





More information about the webkit-dev mailing list