benn_d
10-17-2005, 11:52 PM
Hi,
This is my first post to this site (but I often end up here to solve some problem or other, so for that I thank all contributors)... the time has come though where I have found a 'bug' that I cannot solve and cannot find a solution anywhere...
I have a (now) basic html file with 3 divs stacked on each other (similar in style to a table row), in each of these divs I have a link which when clicked hides (display: none) the clicked div and shows (display: block) a hidden div. This all works great, except in Firefox when I hide/unhide the top div I get a blank row appearing (roughly the same size as the correct row), this does not occur on any of the other rows (nor at all in IE). All rows are exactly the same (beside id) and the issue always occurs on the top div (even if I swap the order around).
The really strange this thing is that in the JS function that I use to hide/unhide divs if I put an alert between the two display actions it all works! My theory is that I think that the pause during the alert allows firefox to catch up with itself and align the divs correctly, take out the alert though and its all mucked up again!
Here is the complete code (no external links)...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Test Page</title>
<script type="text/javascript">
function toggleDiv(show, hide)
{
document.getElementById(hide).style.display = "none";
//alert( '...pause here...' );
document.getElementById(show).style.display = "block";
}
</script>
<style type="text/css">
.rowYellow
{
display: block;
width: 100%;
background-color: red;
margin: 5px 0px 5px 0px;
}
.rowBlue
{
display: none;
width: 100%;
background-color: lightblue;
margin: 5px 0px 5px 0px;
}
</style>
</head>
<body>
<div class="rowYellow" id="rowYellow_1" style='display: block;'>
<a href="#" onclick="toggleDiv( 'rowBlue_1', 'rowYellow_1' )"><b>+</b></a>
</div>
<div class="rowBlue" id="rowBlue_1" style='display: none;'>
<a href="#" onclick="toggleDiv( 'rowYellow_1', 'rowBlue_1' )"><b>-</b></a>
</div>
<div class="rowYellow" id="rowYellow_2" style='display: block;'>
<a href="#" onclick="toggleDiv( 'rowBlue_2', 'rowYellow_2' )"><b>+</b></a>
</div>
<div class="rowBlue" id="rowBlue_2" style='display: none;'>
<a href="#" onclick="toggleDiv( 'rowYellow_2', 'rowBlue_2' )"><b>-</b></a>
</div>
<div class="rowYellow" id="rowYellow_3" style='display: block;'>
<a href="#" onclick="toggleDiv( 'rowBlue_3', 'rowYellow_3' )"><b>+</b></a>
</div>
<div class="rowBlue" id="rowBlue_3" style='display: none;'>
<a href="#" onclick="toggleDiv( 'rowYellow_3', 'rowBlue_3' )"><b>-</b></a>
</div>
</body>
</html>
if anyone has seen this before or knows a way around it I would love to know!!!!
Thanks
Benn
This is my first post to this site (but I often end up here to solve some problem or other, so for that I thank all contributors)... the time has come though where I have found a 'bug' that I cannot solve and cannot find a solution anywhere...
I have a (now) basic html file with 3 divs stacked on each other (similar in style to a table row), in each of these divs I have a link which when clicked hides (display: none) the clicked div and shows (display: block) a hidden div. This all works great, except in Firefox when I hide/unhide the top div I get a blank row appearing (roughly the same size as the correct row), this does not occur on any of the other rows (nor at all in IE). All rows are exactly the same (beside id) and the issue always occurs on the top div (even if I swap the order around).
The really strange this thing is that in the JS function that I use to hide/unhide divs if I put an alert between the two display actions it all works! My theory is that I think that the pause during the alert allows firefox to catch up with itself and align the divs correctly, take out the alert though and its all mucked up again!
Here is the complete code (no external links)...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Test Page</title>
<script type="text/javascript">
function toggleDiv(show, hide)
{
document.getElementById(hide).style.display = "none";
//alert( '...pause here...' );
document.getElementById(show).style.display = "block";
}
</script>
<style type="text/css">
.rowYellow
{
display: block;
width: 100%;
background-color: red;
margin: 5px 0px 5px 0px;
}
.rowBlue
{
display: none;
width: 100%;
background-color: lightblue;
margin: 5px 0px 5px 0px;
}
</style>
</head>
<body>
<div class="rowYellow" id="rowYellow_1" style='display: block;'>
<a href="#" onclick="toggleDiv( 'rowBlue_1', 'rowYellow_1' )"><b>+</b></a>
</div>
<div class="rowBlue" id="rowBlue_1" style='display: none;'>
<a href="#" onclick="toggleDiv( 'rowYellow_1', 'rowBlue_1' )"><b>-</b></a>
</div>
<div class="rowYellow" id="rowYellow_2" style='display: block;'>
<a href="#" onclick="toggleDiv( 'rowBlue_2', 'rowYellow_2' )"><b>+</b></a>
</div>
<div class="rowBlue" id="rowBlue_2" style='display: none;'>
<a href="#" onclick="toggleDiv( 'rowYellow_2', 'rowBlue_2' )"><b>-</b></a>
</div>
<div class="rowYellow" id="rowYellow_3" style='display: block;'>
<a href="#" onclick="toggleDiv( 'rowBlue_3', 'rowYellow_3' )"><b>+</b></a>
</div>
<div class="rowBlue" id="rowBlue_3" style='display: none;'>
<a href="#" onclick="toggleDiv( 'rowYellow_3', 'rowBlue_3' )"><b>-</b></a>
</div>
</body>
</html>
if anyone has seen this before or knows a way around it I would love to know!!!!
Thanks
Benn