function doCommand(cmd)
{
if(is_clean && cmd == 'Undo')
{
restoreContent();
is_clean = false;
}
else
{
if(isAllowed()) document.execCommand(cmd);
}
}

function isAllowed()
{
foo.focus();
return true;
}


<button onClick="doCommand('JustifyLeft');foo.focus();" title="Align Center" class="radio">left</button>
<textarea name = tx rows = 10 cols = 68 id="foo" ></textarea>
من این کد رو پیدا کردم ولی کارنمی کنه ممنون میشم راهنمایی کنید