...

View Full Version : Slide out javascript works in IE but not Firefox ?



MHFactsadmin
01-03-2007, 07:47 PM
I have a script butchered from another function on our site to slideout a table if a link is clicked on and slide it back in if the link is clicked again

This all works fine and dandy in IE but in Firefox the table slides down about 1 pixel and then stops !!

Here is the script we use


OriginalHeight = new Array();
function SlideOut(object,dest,direc) {
// get height and remove the 'px'
h = document.getElementById(object).style.height;
strip=/[px]/gi; h = h.replace(strip,''); h = parseInt(h);
// set sizes and see if we are finished
if (direc == 1) { h+=20; keepgoing = (dest >= h) ? true : false; } else { h-=20; keepgoing = (dest < h) ? true : false; }
if (keepgoing) {
// not done yet, timeout so we can keep going
document.getElementById(object).style.height = h + 'px';
setTimeout("SlideOut('" + object + "'," + dest + "," + direc + ");",60);
} else {
// either hide it or return to original size
if (direc == 0) { document.getElementById(object).style.display = 'none'; } else { document.getElementById(object).style.height = OriginalHeight[object]+2+'px'; }
}
}

function ToggleBox(object) {
// set original height if it's not already set
if (!OriginalHeight[object]) {
if (document.getElementById(object).clientHeight == 0) {
// if our element is hidden we need to prepare it.. show it, grab the height, shrink it to 0, and hide it again!
document.getElementById(object).style.display = 'block';
OriginalHeight[object] = document.getElementById(object).clientHeight;
document.getElementById(object).style.height = 0; document.getElementById(object).style.display = 'none';
}
OriginalHeight[object] = document.getElementById(object).clientHeight;
}
// expand or contract
if (document.getElementById(object).style.display == 'block') {
document.getElementById(object).style.height = OriginalHeight[object];
SlideOut(object,5,0);
} else {
document.getElementById(object).style.display = 'block';
SlideOut(object,OriginalHeight[object],1);
}
}

any help much appreciated as i'm a php coder not javascript ;)

you can see the effect for yourself on the following url
http://www.motorhomefacts.com/ftopicp-197115.html#197115
Click on the Show them Below >> link which is beneath nukeadmins avatar and the bottom of that post should slideout down to show some usernames



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum