setExpression takes client processor to 100%

J

Jack Wright

Dear All,

I have been trying to use the following:

document.getElementById('someId').setExpression('someExpression');

This works ok.

But in my actual implementation, I have over 20 different elements
which need to be positioned using this method. When I made the code, I
found that my CPU would be at 100% for even trival events such as
mouseover() and mouseout()

Am I doing something wrong?

Thanks and regards,
Jack
 
R

Richard Cornford

Jack Wright said:
I have been trying to use the following:

document.getElementById('someId').setExpression('someExpression');

This works ok.

But in my actual implementation, I have over 20 different
elements which need to be positioned using this method.

While you can position elements using that method (though only on recent
IE browsers) it is doubtful that you *need* to. There are plenty of
other ways of positioning elements, including method that will work
across many (all) dynamic browsers.
When I made the code, I found that my CPU would be at 100% for even
trival events such as mouseover() and mouseout()

Yes, expressions get applied frequently and repeatedly, if you use more
than a couple it is easy to overload IE, and the more complex the
expression the more work is needed for each.
Am I doing something wrong?

The balance of probability is that you don't need to position elements
with an expression and that identifying when you do need to position
them will allow you to implement their positioning in a way that doesn't
overburden the browser.

For animated positioning some sort of timer driven activity would
probably do. Animation is smooth at 40 millisecond intervals (though
browser timers are rarely capable of achieving that rate, or that
precision). Otherwise, event driven re-positioning would be better, an
initial placement and then re-positioning in response to onresize and/or
user interaction.

And for some re-positioning, say in response to user's re-setting their
display font size, an appropriate use of CSS units for positioning may
avoid the need to involve javascript in the process at all.

Richard.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top