setExpression takes client processor to 100%

Discussion in 'Javascript' started by Jack Wright, Feb 12, 2004.

  1. Jack Wright

    Jack Wright Guest

    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
    Jack Wright, Feb 12, 2004
    #1
    1. Advertising

  2. "Jack Wright" <> wrote in message
    news:...
    >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.
    Richard Cornford, Feb 12, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Cynthia
    Replies:
    2
    Views:
    1,046
    Guest
    Nov 25, 2003
  2. brahatha
    Replies:
    1
    Views:
    657
  3. Jorch
    Replies:
    5
    Views:
    139
  4. fred
    Replies:
    3
    Views:
    278
    Zifud
    Mar 17, 2005
  5. Replies:
    5
    Views:
    886
Loading...

Share This Page