Jump to content


Rafael P L

Member Since 30/07/2011
Offline Last Active 01/12/2011, 21:03
-----

Topics I've Started

Problema Com Loop

30/07/2011, 22:47

Pessoal, estou escrevendo um código para que reconheça uma palavra no textarea e a selecione. Veja abaixo.

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.

IPB Skin By Virteq