...

View Full Version : setExpression()



sunny
02-12-2004, 08:07 AM
Hi all,

I am using the following

document.getElementByID('someID').style.setExpression('someExpression')

I have over 20 different elements (DIV's) on the page which I align using this method.

But, after the positioning, the CPU goes to 100% even for trival things such as mouseover() and mouseout()

Please refer to this article for an exmple of what I hoped to do:

http://www.javascriptkit.com/dhtmltutors/dynproperty.shtml

Am I doing something wrong?

Any help would be appreciated.

Take Care

Garadon
02-12-2004, 11:20 AM
If one wants help optimising ones code, one would think that poasting ones code migth help?

ahosang
02-14-2004, 01:13 AM
please post code. It may have something to do with some infinite loop in the scripting engine.

brothercake
02-15-2004, 04:19 PM
An expression is a dynamic property - it changes continually. If you set a value on an element using an expression then, depending on how many there are and what else affects the value, it could be very expensive - sometimes too expensive to use.

What you could try is a one-time-use expression (invented by jkd) which is only evaluated once. Here's an example:



width:expression("auto",this.runtimeStyle.width=this.parentNode.currentStyle.width);


It contains two expressions, but only the second is returned - using "this.runtimeStyle" for the second expression removes the dynamic property, and so the value never gets re-evaluated. You can use it to do operations that would otherwise be too intense.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum