Acabei de fazer um código que talvez te ajude. Veja se te serve:
var AB_TOGGLE_DISPLAY_ON = "ab_show";
var AB_TOGGLE_DISPLAY_OFF = "ab_hide";
var IE =(navigator.appVersion.indexOf("MSIE") > - 1);
var LEFT = 0;
var TOP = 1;
function toggleDisplay(toggler, divTarget, divSubst){
if(divTarget && toggler){
/*Esconde a divTarget*/
var targetClasses = divTarget.className.split(" ");
var newClassName = "";
var displayClassFound = false;
for(i = 0; i < targetClasses.length; i++){
if(!displayClassFound){
if(targetClasses[i] == AB_TOGGLE_DISPLAY_ON){
newClassName += AB_TOGGLE_DISPLAY_OFF;
if(toggler.src)
toggler.src = "img_01.jpg";
displayClassFound = true;
}else if(targetClasses[i] == AB_TOGGLE_DISPLAY_OFF){
newClassName += AB_TOGGLE_DISPLAY_ON;
if(toggler.src)
toggler.src = "img_00.jpg";
displayClassFound = true;
}else
newClassName += targetClasses[i];
}else{
newClassName += targetClasses[i];
}
if(i + 1 < targetClasses.length)
newClassName += " ";
}
divTarget.className = newClassName;
if(divSubst){
var divSubstLocation = getDivLocation(divSubst);
var divTargetLocation = getDivLocation(divTarget);
setDivLocation(divSubst, divTargetLocation);
setDivLocation(divTarget, divSubstLocation);
}
}
}
function getObjRef(objId){
var obj;
if(IE){
obj = eval("document.all." + objId);
}else {
if(window.document.getElementById != null){
obj = window.document.getElementById(objId);
}else if(window.document.all != null){
obj = window.document.all(objId);
}else if(window.document.layers != null){
obj = document.layers[objId];
}else{
obj = objId;
}
}
return obj;
}
function getDivLocation(obj){
if(!obj || !obj.tagName || obj.tagName.toLowerCase() != "div")
return null;
var location = new Array(2);
location[LEFT] = obj.offsetLeft;
location[TOP] = obj.offsetTop;
return location;
}
function setDivLocation(obj, location){
if(!obj || !obj.tagName || obj.tagName.toLowerCase() != "div")
return false;
if(!location || !location.length || location.length != 2)
return false;
obj.style.left = location[LEFT];
obj.style.top = location[TOP];
return true;
}
Aqui na minha máquina tá funfando tanto no IE quanto no FireFox 1.0.7
Qq coisa, mande outro post, ok?
Edição feita por: Mantu, 13/04/2006, 14:38.