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, "&"); //text = text.replace(/</g, "<"); //text = text.replace(/>/g, ">"); //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
Post a Comment