Guest_imported
New member
- Jan 1, 1970
- 0
I have this simple JavaScript code, with a text to textarea function:
<script language="JavaScript">
<!--
function change_text(number)
{
if(number == 0)
document.form.textarea.value = "Text element 1";
else if(number == 1)
document. form.textarea.value = "Text element 2";
.
}
-->
</script>
The performance of the script is though closely related to the amount of characters in the text, where I tested have observed the following:
Test 1)
10 text elements with exactly 15 characters each is okay (loading time < 1. sec.)
10 text elements with exactly 16 characters each is NOT okay (loading time > 10 sec.)
Test 2)
4 text elements with exactly 138 characters each is okay (loading time < 1. sec.)
4 text elements with exactly 139 characters each is NOT okay (loading time > 10. sec.)
I cant se any relations between the two tests, except a significant time delay when I increase the amount of charters with one!!
I have tried the code with use of an array, but the performance is the same!
Does anyone know how to overcome this problem - so the loading of the page becomes quicker?
Thanks in advanced,
Bo
<script language="JavaScript">
<!--
function change_text(number)
{
if(number == 0)
document.form.textarea.value = "Text element 1";
else if(number == 1)
document. form.textarea.value = "Text element 2";
.
}
-->
</script>
The performance of the script is though closely related to the amount of characters in the text, where I tested have observed the following:
Test 1)
10 text elements with exactly 15 characters each is okay (loading time < 1. sec.)
10 text elements with exactly 16 characters each is NOT okay (loading time > 10 sec.)
Test 2)
4 text elements with exactly 138 characters each is okay (loading time < 1. sec.)
4 text elements with exactly 139 characters each is NOT okay (loading time > 10. sec.)
I cant se any relations between the two tests, except a significant time delay when I increase the amount of charters with one!!
I have tried the code with use of an array, but the performance is the same!
Does anyone know how to overcome this problem - so the loading of the page becomes quicker?
Thanks in advanced,
Bo