T
tabert
I want to use JavaScript when a button is clicked to show and hide a
SPAN or DIV. This works in both IE and Netscape, but what I'd like to
happen is for there to be no white space where the hidden div is.
I start with two visible divs and in between them are two more hidden
ones...in Firefox this works fine--the two visible ones are right next
to each other, the button fires the script and the other div shows up
in the middle. Another button hides the div and the original two move
back together without space between them.
However on IE the two visible divs are separated by the amount of
whitespace that would be needed if the two hidden divs were actually
visible. They show and hide correctly, but the whitespace remains.
How can I fix this?
Thanks in advance!
Below is the code I'm using:
<style type="text/css">
..hidden
{
background:white;
height:0px;
overflow:hidden;
}
..fullsize
{
background:white;
}
</style>
<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
function toggle(id){
if (ns4){
document.layers[id].className =
(document.layers[id].className=='hidden') ? 'fullsize' : 'hidden';
}else if (ie4) {
document.all[id].className = (document.all[id].className=='hidden')
? 'fullsize' : 'hidden';
}else{
var divID = document.getElementById([id]);
divID.className = (divID.className=='hidden') ? 'fullsize' :
'hidden';
}
}
// Show/Hide functions for non-pointer layer/objects
function show(id) {
if (ns4){
document.layers[id].visibility = "show";
toggle(id);
}else if (ie4){
alert('ie4 fired');
document.all[id].style.visibility = "visible";
toggle(id);
}else{
var divID = document.getElementById(id);
divID.setAttribute('style', 'hidden:false');
toggle(id);
}
}
function hide(id) {
if (ns4){
document.layers[id].visibility = "hide";
toggle(id);
}else if (ie4){
document.all[id].style.visibility = "hidden";
toggle(id);
}else{
var divID = document.getElementById([id]);
divID.style.visibility = 'hidden';
toggle(id);
}
}
</SCRIPT>
SPAN or DIV. This works in both IE and Netscape, but what I'd like to
happen is for there to be no white space where the hidden div is.
I start with two visible divs and in between them are two more hidden
ones...in Firefox this works fine--the two visible ones are right next
to each other, the button fires the script and the other div shows up
in the middle. Another button hides the div and the original two move
back together without space between them.
However on IE the two visible divs are separated by the amount of
whitespace that would be needed if the two hidden divs were actually
visible. They show and hide correctly, but the whitespace remains.
How can I fix this?
Thanks in advance!
Below is the code I'm using:
<style type="text/css">
..hidden
{
background:white;
height:0px;
overflow:hidden;
}
..fullsize
{
background:white;
}
</style>
<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
function toggle(id){
if (ns4){
document.layers[id].className =
(document.layers[id].className=='hidden') ? 'fullsize' : 'hidden';
}else if (ie4) {
document.all[id].className = (document.all[id].className=='hidden')
? 'fullsize' : 'hidden';
}else{
var divID = document.getElementById([id]);
divID.className = (divID.className=='hidden') ? 'fullsize' :
'hidden';
}
}
// Show/Hide functions for non-pointer layer/objects
function show(id) {
if (ns4){
document.layers[id].visibility = "show";
toggle(id);
}else if (ie4){
alert('ie4 fired');
document.all[id].style.visibility = "visible";
toggle(id);
}else{
var divID = document.getElementById(id);
divID.setAttribute('style', 'hidden:false');
toggle(id);
}
}
function hide(id) {
if (ns4){
document.layers[id].visibility = "hide";
toggle(id);
}else if (ie4){
document.all[id].style.visibility = "hidden";
toggle(id);
}else{
var divID = document.getElementById([id]);
divID.style.visibility = 'hidden';
toggle(id);
}
}
</SCRIPT>