Intexk
|
| Posted: 12/15/2005, 4:07 AM |
|
This wonderfull function (forms_onload) found in functions.js is making all pages displays very slow (usually when u have lots of elements in a page)
For example i have one page with an editable grid (1200 rows)..and it takes more than 45 seconds to render the page(not to load the html).
The Problem is this
for(i = 0; i < forms.length; i++)
for (j = 0; j < form.elements.length; j++)
if u do that in new internet explorers (mozilla too),for each iteration in the loop it will recount all elements...and that is a lot of time wasted.
I Suggest u change that function to something like this:
function forms_onload()
{
var forms = document.forms;
var i, j, elm, form;
var ic=forms.length;
for(i = 0; i < ic; i++)
{
form = forms;
if (typeof(form.onLoad) == "function") form.onLoad();
var jc=form.elements.length;
for (j = 0; j < jc; j++)
{
elm = form.elements[j];
if (typeof(elm.onLoad) == "function") elm.onLoad();
}
}
return true;
}
|
|
|
 |
E43509
Posts: 283
|
| Posted: 12/15/2005, 5:56 AM |
|
Curious, what version? 2 or 3 ccs?
|
 |
 |
Intexk
|
| Posted: 12/16/2005, 2:13 AM |
|
both versions, that forms_onload hasn't changed anything since long time ago.
|
|
|
 |
Intexk
|
| Posted: 12/16/2005, 5:32 AM |
|
this is light speed version of forms_onload
function forms_onload()
{
for(var form in document.forms)
{
if (typeof(form.onLoad) == "function") form.onLoad();
for(var elm in form.elements)
{
if (typeof(elm.onLoad) == "function") elm.onLoad();
}
}
return true;
}
|
|
|
 |
Intexk
|
| Posted: 12/19/2005, 4:16 AM |
|
above functions doesn't work very well...(or nothing..lol) 
but this one rocks.
function forms_onload()
{
for(var i = 0,form ;form =forms; i++)
{
if (typeof(form.onLoad) == "function") form.onLoad();
for (var j = 0,elm;elm=form.elements[j]; j++)
{
if (typeof(elm.onLoad) == "function") elm.onLoad();
}
}
return true;
}
|
|
|
 |
Intexk
|
| Posted: 12/19/2005, 4:38 AM |
|
function forms_onload()
{
var forms=document.forms;
for(var i = 0,form ;form =forms [ i ] ; i++)
{
if (typeof(form.onLoad) == "function") form.onLoad();
for (var j = 0,elm;elm=form.elements [ j ] ; j++)
{
if (typeof(elm.onLoad) == "function") elm.onLoad();
}
}
return true;
}
|
|
|
 |
|