T
The Natural Philosopher
I raised this last week, and found a reasonable hack, but would like to
get a better solution, and hopefully a more elegant solution..that runs
a heck of a lot faster.
basically its a flyout menu system,
of this sort of form
<Div frame>
<div an elemenet onmuosover selcet child frame and cancel others>click
me</div>
.......
...
</div> <!-- end the frame. -->
This lot is php created, so its no big deal to utterly change the 2000
odd elements with mouseovers attached.
Now currently each frame has an ID so I can traverse them all, switching
off the ones no longer wanted, and switching on the one that is.
The trouble is, the HTML and script to tell each JS onmouseover which to
turn on and which to turn off would be massive.
That would kill the page load time.
By traversing all the divs, till the right ones are found, its not too
bad, but when I added a second example of this type to the same page,
there seems to be a 4 times slowdown.
Its got unacceptable. i have around 2000 divs on the page, and scanning
the lot and checking each one seems to take about half a second in
firefox, and nearly two seconds in Ie7.
My previous hack consisted in registering which ones were relevant into
a table. Do if a div had been turned ON, it would be in the table, and
if not well..then you had to find it to turn it on. This worked fairly
well after a few slow scans, as te tale was then mostly complete.
But it would be nice to know a better way of creating a subset of all
the divs in the page that cold be searched faster. Preferable when te
page is assembled, rather than when it is run.
So teh questions are of two basic kinds.
Firstly, how can you at page creation time build a set of references to
DOM objects..?
Sort of <div <script> register(this)</script>> </div> ?
Is anything like that possible?
If thats not possible how is teh DOM structired..fir example if I give
te parent conainers and ID, can I merely search their children, rather
then the whole p[ge?
i.e. if I do a
document.geteElementById('container').getElementsByTagName('div') is
that efficient to isolate only those divs inside that container?
Another useful one would be a docment.getElementsByZIndex('n') :-()
So how to efficiently either register, or find, certain divs is the
problem. Given a bloody lot of them in the first place, most of which
are superfluous to the search.
get a better solution, and hopefully a more elegant solution..that runs
a heck of a lot faster.
basically its a flyout menu system,
of this sort of form
<Div frame>
<div an elemenet onmuosover selcet child frame and cancel others>click
me</div>
.......
...
</div> <!-- end the frame. -->
This lot is php created, so its no big deal to utterly change the 2000
odd elements with mouseovers attached.
Now currently each frame has an ID so I can traverse them all, switching
off the ones no longer wanted, and switching on the one that is.
The trouble is, the HTML and script to tell each JS onmouseover which to
turn on and which to turn off would be massive.
That would kill the page load time.
By traversing all the divs, till the right ones are found, its not too
bad, but when I added a second example of this type to the same page,
there seems to be a 4 times slowdown.
Its got unacceptable. i have around 2000 divs on the page, and scanning
the lot and checking each one seems to take about half a second in
firefox, and nearly two seconds in Ie7.
My previous hack consisted in registering which ones were relevant into
a table. Do if a div had been turned ON, it would be in the table, and
if not well..then you had to find it to turn it on. This worked fairly
well after a few slow scans, as te tale was then mostly complete.
But it would be nice to know a better way of creating a subset of all
the divs in the page that cold be searched faster. Preferable when te
page is assembled, rather than when it is run.
So teh questions are of two basic kinds.
Firstly, how can you at page creation time build a set of references to
DOM objects..?
Sort of <div <script> register(this)</script>> </div> ?
Is anything like that possible?
If thats not possible how is teh DOM structired..fir example if I give
te parent conainers and ID, can I merely search their children, rather
then the whole p[ge?
i.e. if I do a
document.geteElementById('container').getElementsByTagName('div') is
that efficient to isolate only those divs inside that container?
Another useful one would be a docment.getElementsByZIndex('n') :-()
So how to efficiently either register, or find, certain divs is the
problem. Given a bloody lot of them in the first place, most of which
are superfluous to the search.