HTMLTextAreaElement.prototype.wordDetect = function()
{
var startCursor = this.selectionStart;
var endCursor = this.selectionEnd;
var txt = this.value;
while (txt.charAt(startCursor) != ' ' || txt.charAt(startCursor) != '\n' || this.selectionStart !== 0)
{
this.selectionStart = startCursor;
this.focus();
startCursor--;
}
while (txt.charAt(endCursor) != ' ' || txt.charAt(endCursor) != '\n' || this.selectionEnd !== 0)
{
endCursor++;
this.focus();
this.selectionEnd = endCursor;
}
/**/
};
Só que estou tendo problema com os loops. Estão entrando em loop infinito, mas não deviam. Estou testando ainda apenas no FF.
Edição feita por: Rafael P L, 30/07/2011, 23:00.