Show/Hide All Elements by Tag Name
12
Allows you to hide all elements on an HTML page by their tag name. Extremely handy in getting around the "Windowless Elements" problem in IE, which is a bug that puts certain elements, most commonly select boxes, on top of any other element, no matter what. As you can imagine, this causes real problems with DHTML drop-down menus and such like. This is the simplest and quickest fix I've come up with, I simply set this function to run alongside the drop-down and all of the select tags vanish before a menu drops, then I run the show function when the menu retracts.
function showAllByTag(tagName,dispType) {
var elements = document.getElementsByTagName(tagName);
var i = 0;
if (dispType == "") {
dispType = inline;
}
while (i < elements.length) {
elements[i].style.display = dispType;
i++;
}
}
function hideAllByTag(tagName) {
var elements = document.getElementsByTagName(tagName);
var i = 0;
while (i < elements.length) {
elements[i].style.display = "none";
i++;
}
}






// no actions
}
AllByTag.setStyleDisplay = function(tagName,value) {
var elements = document.getElementsByTagName(tagName);
for (var i = 0; i < elements.length; i++) {
elements[i].style.display = value;
}
}
AllByTag.show = function(tagName,dispType) {
AllByTag.setStyleDisplay(tagName, dispType ? dispType : 'inline');
}
AllByTag.hide = function(tagName,dispType) {
AllByTag.setStyleDisplay(tagName, 'none');
}
http://www.artima.com/intv/dry.html