HighDots Forums  

Re: How do I save and restore CSS properties?

Javascript JavaScript language (comp.lang.javascript)


Discuss Re: How do I save and restore CSS properties? in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
monkeybug07
 
Posts: n/a

Default Re: How do I save and restore CSS properties? - 06-26-2003 , 09:55 AM







Thank you very much. I think the idea of .cssText is all I need. I
can just save and restore this property for the object. Is there any
pitfalls that I should be aware of?

Is .cssText an W3C standard?



I also have a few questions about your replies

<snip>




Quote:
function SaveCSS(sElement) {

/* store current css properties */
adminSaveState[sElement] = document.getElementById(sElement);

Here, all you save is a reference to the DOM node.

}
In the previous code, all I am saving is a reference(pointer) to the
object? What would I need to do if I have to save a copy of the
object?



<snip>

Quote:
I tried this:

function getCSSState(id) {
var srcStyle = document.getElementById(id).style;
var dstStyle = {};
for (var i in srcStyle) {
dstStyle[i]=srcStyle[i];
}
return dstStyle;
}

function setCSSStyle(id,srcStyle) {
var dstStyle = document.getElementById(id).style;
for (var i in dstStyle) {
dstStyle[i]=srcStyle[i]; // sets to undefined if not in srcStyle
}
for (i in srcStyle) {
if (dstStyle[i] === undefined) {
dstStyle[i]=srcStyle[i]; // sets those not in dstStyle, if any.
}
}
}

It works - kindof - in IE and Mozilla, but not in Opera. The properties
are not enumerable.

How would you call these functions? I originally declared a global
associative array to store copies of various objects. From what I see
from your functions, you are creating an associative array for a
single object? This probably ties in with my previous question.

thanks again




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.