glopal Posted August 10, 2009 Share Posted August 10, 2009 I have this javascript that runs on resize... <body onresize = "myfunction();">It grabs the "container" div by id, then looks at its offset width. If the width is less than 800, it loops through all the "img" divs ("img" is the class name, stfu, it works), and sets cssFloat = 'none';Basically, if you zoom in enough so that the floats are squeezing text and messing up headers, it breaks the float. And it works rather nicely.My question is: Can you revert changes made to style in javascript?Some explanation: On the else of "if(width<800)" I want it to reset all of the floats back to what they were originally (Some are left, some are right).I'm under the impression that going obj.style.cssFloat = 'none' is setting the inline style of that element... right? So if I were to go obj.style = "", wouldnt that clear the inline style, thus reverting back to the original style from the style sheet? I tried it, it doesnt appear to work.Any ideas? Link to comment Share on other sites More sharing options...
justsomeguy Posted August 10, 2009 Share Posted August 10, 2009 If you clear the property it uses the default value, whatever that is. Not the original value, but whatever the default for that property is defined as. You could use Firebug to verify, but as far as I know it doesn't store the original style information. If you wanted to keep track of that you would need to do it yourself. Link to comment Share on other sites More sharing options...
jeffman Posted August 10, 2009 Share Posted August 10, 2009 obj.style = "" throws an error.You'd do better to have a unique class for each state, and then toggle obj.className. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.