> I can't, but thanks. The goal is to not have to set individual style
elements in the function, but to allow that which calls the function to
be able to pass what it wants to set. I'm making a generic function to be
included on other pages.
I don't understand why not. If you want to create a generic interface,
set/getAttribute is as generic as it gets. Instead, creating a generic
interface, that works, is more powerfull. Imagine:
function setStuff(elm,attrib,prop) {
if (attrib == "style") {
// first, split prop by ;
...
for (var i = 0; i < props.length; i++) {
// assuming attribs and propsvalue arrays
eval("elm.style."+attribs[i]+"="+propsvalue[i]);
}
} else if (bla bla) {
..
}
}
No, it's not optimal, but there's no reason not to use property g/setters,
where these are available. For the more simple stuff, just go:
if (blah) {
eval("elm."+attrib+"="+prop);
}
And in a last case, assuming the attrib wasn't recognized by any case, just
fall back on "setAttribute".
As far as I can see, the interface should be no different from
setAttribute, except you can, where browser bugs deem necessary, just use
the normal properties.
Regards,
Svend