javascript - How to force update HTML's TextArea element? -



javascript - How to force update HTML's TextArea element? -

sorry newbie question it's related webkit issue. have next js code:

var module = { prerun: [], postrun: [], print: (function() { var element = document.getelementbyid('output'); if (element) element.value = ''; // clear browser cache homecoming function(text) { text = array.prototype.slice.call(arguments).join(' '); // these replacements necessary if render raw html //text = text.replace(/&/g, "&amp;"); //text = text.replace(/</g, "&lt;"); //text = text.replace(/>/g, "&gt;"); //text = text.replace('\n', '<br>', 'g'); console.log(text); if (element) { element.value += text + "\n"; console.log('updated element.value'); element.scrolltop = element.scrollheight; // focus on bottom } }; })

element textarea element:

<textarea id="output" rows="8"></textarea>

i have code printf using function , shows prompt type user name. expect see 'updated element.value' in browser console , printed text in textarea before prompt dialog shown.

how can forcefulness textarea refresh after it's changed (element.value += text + "\n")?

it works expected in chrome/firefox fails in safari(webkit) - can't see output @ moment prompt dialog shown.

to me sounds can't done, there might webkit specific hacks i'm not aware about. maybe browsers both updates during same render cycle you'd expect, safari displays prompt first , somehow pauses remaining updates until prompt dismissed.

the obvious workaround like

print('lorem ipsum'); settimeout(function(){ var response = prompt('my question here'); //handle response }, 10);

which guarantee textarea update happens before prompt locks things.

javascript html textarea

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -