PDA

View Full Version : expression() for Netscape/Mozilla?


diades
08-16-2002, 05:16 PM
Hi Guys

I have been looking and looking to no avail.

IE has had, since IE4, the use of:
expression( [function or script expression])
within a style block declaration to dynamically set the value of a css property.
Does Netscape v6+ and/or mozilla have anything of the sort?

<style type="text/css">
div{position:absolute;
top:expression((document.documentElement.offsetHeight * 0.15) + 'px');}
</style>


nb: If this is in the wrong forum, I apolagise, just move it wherever:)

jkd
08-16-2002, 06:46 PM
There is no direct equivalent for expression() is NS6.

If I were you, I'd investigate the watch() method of an object. You can essentially setup "listeners" for object properties and execute a function when the value is changed. The function could be used to dynamically alter a style attribute for example.

As for the appropriate forum, expression() has nothing to do with DOM scripting, but has a lot to do with JS and CSS... if this was the old JSK forum, --> DHTML, but since its not, I feel... Javascript Programming. :D
(Because IE has a whole createExpression() thing going as well...)

diades
08-16-2002, 09:58 PM
Hey Jason

So you are saying that by using watch, I can reset the fixed css sizes of elements when the browser is resized (N6+/Moz) to new fixed sizes in proportion to the new browser size?

jkd
08-16-2002, 10:15 PM
You can fire an event when a property value changes. This event may include dynamically changing the style attribute. So yes.

I would assume:

window.watch('innerWidth', function(propName, oldValue, newValue) {
//do something
});

Would work (though I haven't tested it).

diades
08-16-2002, 10:33 PM
Only one way to find out:D If you see sparks across the pond, duck:D