I've been having a debate with my self recently.
I write small transportable javascript functions and I find myself debating about using the ".className" or the ".style" property to style my DOM created objects.
If I use className then I can no longer post code or hand out a snippets that actually work by themselves. They have to be accompanied by a CSS file, which if lost will cause the code to break (often invisibly to the person trying to use it).
On the other hand, doing something like:is a heck of a lot easier thanCode:WhiteOutDiv.className = "someclassname";Code:var currOpacity = 50; WhiteOutDiv.style.display = 'none'; WhiteOutDiv.style.zIndex = "499"; WhiteOutDiv.style.position = "absolute"; WhiteOutDiv.style.filter = "alpha(opacity=" + currOpacity + ")"; // IE WhiteOutDiv.style.opacity = currOpacity / 100; // Firefox, etc.. WhiteOutDiv.style.backgroundColor = "#ffffff"; WhiteOutDiv.style.top = "0px"; WhiteOutDiv.style.left = "0px"; WhiteOutDiv.innerHTML = " " WhiteOutDiv.style.height= "100%"; WhiteOutDiv.style.width = "100%";


Reply With Quote
Bookmarks