Firefox throwing js error in for loop “allocation size overflow”

前端 未结 2 1011
南方客
南方客 2021-01-05 16:16

Below is my code

Same code is working in local server but not in live.

    htmlC = \"\";
    htmlC += \'');
for(i=1 ; i<=tot_pages ; i++)
{
        if(i.toString() == document.frmlist.start.value)
        {
            htmlBuffer.push("");
        }
        else
        {
            htmlBuffer.push("");
        }
}   
htmlBuffer.push('');

htmlC = htmlBuffer.join('\n');

The above will define an array, to which you push each "row" onto. It will dynamically allocate memory needed for the expanding data, and finally, you allocate 1 string for the total amount of data . This is much more efficient. I don't know if this is the actual problem in your case (since we don't know what tot_pages are), but it's never a bad idea to avoid string concatenations in loops anyway.

提交回复
热议问题