473,378 Members | 1,518 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Showing and Hiding DIVs in FireFox

I have the following html sample, where I'd like to have a show and
hide two divs, one replacing the other. Following these two divs is a
third div (the bluediv) which I would like to have placed right up
directly below to the first or second div, depending on which is
showing.

If you load the html in Firefox, and then click on the "Edit" link you
can see that the first div is hidden, the second div is shown, however
the third div is place away from the second div. I've noticed that the
gap is about the size of the hidden div.

Is there a way to do this div show/hide, and still have the third div
lineup directly below the shown div?

Under IE the bluediv is placed exactly as I would like, directly under
the shown div.

Thanks for your help,

Greg

<html>

<script>
function showGeneralEdit(show) {
if (show) {
document.getElementById("GeneralEdit").style.displ ay = "";
document.getElementById("GeneralStatic").style.dis play = "none";
} else {
document.getElementById("GeneralEdit").style.displ ay = "none";
document.getElementById("GeneralStatic").style.dis play = "";
}
}
</script>
<style>

..Section {
border: 1px solid black;
}

..BlueDiv {
background-color:blue;
color:white;
}

</style>

<body>
<div class="Section" id="GeneralStatic">
<div>
<a href="javascript:showGeneralEdit(true)">Edit</a> in static mode
</div>
</div>
<div style="display:none;" class="Section" id="GeneralEdit">
<div>
<a href="javascript:showGeneralEdit(false)">Cancel</a> in edit mode
</div>
</div>
<div class="BlueDiv">
<div>
blue div
</div>
</div>
</body>
</html>

Oct 11 '05 #1
5 2170

gr********@gmail.com wrote:
I have the following html sample, where I'd like to have a show and
hide two divs, one replacing the other. Following these two divs is a
third div (the bluediv) which I would like to have placed right up
directly below to the first or second div, depending on which is
showing.

If you load the html in Firefox, and then click on the "Edit" link you
can see that the first div is hidden, the second div is shown, however
the third div is place away from the second div. I've noticed that the
gap is about the size of the hidden div.

Is there a way to do this div show/hide, and still have the third div
lineup directly below the shown div?

Under IE the bluediv is placed exactly as I would like, directly under
the shown div.

Thanks for your help,

Greg

<html>
Where is doctype?
No doctype = quirks mode.

<script>
function showGeneralEdit(show) {
if (show) {
document.getElementById("GeneralEdit").style.displ ay = "";
document.getElementById("GeneralStatic").style.dis play = "none";
} else {
document.getElementById("GeneralEdit").style.displ ay = "none";
document.getElementById("GeneralStatic").style.dis play = "";
}
}


I use this as well as set visibility to "visible" or "hidden" in my
scripts that toggle divs, and I don't have an issue with it taking up
space, so try that.
And use doctype.
Quirks mode is responsible for all kinds of cross-browser issues, IME.

Oct 11 '05 #2
I try this but the results are the same...

Any other ideas?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html>

<head>

<script>
function showGeneralEdit(show) {
if (show) {
document.getElementById("GeneralEdit").style.displ ay = "";
document.getElementById("GeneralStatic").style.dis play = "none";
} else {
document.getElementById("GeneralEdit").style.displ ay = "none";
document.getElementById("GeneralStatic").style.dis play = "";
}
}
</script>

<style>

Oct 11 '05 #3
gr********@gmail.com wrote:
I have the following html sample, where I'd like to have a show and
hide two divs, one replacing the other. Following these two divs is a
third div (the bluediv) which I would like to have placed right up
directly below to the first or second div, depending on which is
showing.

If you load the html in Firefox, and then click on the "Edit" link you
can see that the first div is hidden, the second div is shown, however
the third div is place away from the second div. I've noticed that the
gap is about the size of the hidden div.

Is there a way to do this div show/hide, and still have the third div
lineup directly below the shown div?

Under IE the bluediv is placed exactly as I would like, directly under
the shown div.

The difference between the two browsers is that Firefox inserts text
nodes in the document to preserve whitespace in the source code, IE
doesn't. How this whitespace is handled is causing your problem.

The whitespace between the end of the 'GeneralStatic' div and the start
of the 'GeneralEdit' div causes the space that you see. For some
reason, the treatment of this whitespace is affecting how the divs are
shown - the behaviour seems a bit bizarre to me. Remove it and all is well.

You might try posting in a comp.infosystems.www.authoring.html to see if
they have a real answer, or look through the Mozilla bug log.

[...] <body>
<div class="Section" id="GeneralStatic">
<div>
<a href="javascript:showGeneralEdit(true)">Edit</a> in static mode
</div>
</div>
<div style="display:none;" class="Section" id="GeneralEdit">
Remove the whitespace between the closing 'GeneralStatic' div tag and
opening 'GeneralEdit' div tag:

</div><div style="display:none;" class="Section" id="GeneralEdit">
<div>
<a href="javascript:showGeneralEdit(false)">Cancel</a> in edit mode
</div>


[...]

--
Rob
Oct 12 '05 #4
> "gr********@gmail.com" <gr********@gmail.com> wrote:
news:11**********************@f14g2000cwb.googlegr oups.com....

I have the following html sample, where I'd like to have a show and
hide two divs, one replacing the other. Following these two divs is a
third div (the bluediv) which I would like to have placed right up
directly below to the first or second div, depending on which is
showing.

If you load the html in Firefox, and then click on the "Edit" link you
can see that the first div is hidden, the second div is shown, however
the third div is place away from the second div. I've noticed that the
gap is about the size of the hidden div.

Is there a way to do this div show/hide, and still have the third div
lineup directly below the shown div?

Under IE the bluediv is placed exactly as I would like, directly under
the shown div.

<html>

<script>
function showGeneralEdit(show) {
if (show) {
document.getElementById("GeneralEdit").style.displ ay = "";
document.getElementById("GeneralStatic").style.dis play = "none";
} else {
document.getElementById("GeneralEdit").style.displ ay = "none";
document.getElementById("GeneralStatic").style.dis play = "";
}
}
</script>

<style>

.Section {
border: 1px solid black;
}

.BlueDiv {
background-color:blue;
color:white;
}

</style>

<body>
<div class="Section" id="GeneralStatic">
<div>
<a href="javascript:showGeneralEdit(true)">Edit</a> in static mode
</div>
</div>
<div style="display:none;" class="Section" id="GeneralEdit">
<div>
<a href="javascript:showGeneralEdit(false)">Cancel</a> in edit
mode </div>
</div>
<div class="BlueDiv">
<div>
blue div
</div>
</div>
</body>
</html>


<script type="text/javascript">
function showGeneralEdit() {
var diva = document.getElementById("GeneralEdit").style;
var divb = document.getElementById("GeneralStatic").style;
(diva.display=='')?
(diva.display='none')&(divb.display=''):
(diva.display='')&(divb.display='none');
document.body.style.display='none';
document.body.style.display='';
}
</script>

--
BootNic Wednesday, October 12, 2005 1:03 AM

Humor is emotional chaos remembered in tranquility.
*James Thurber*
Oct 12 '05 #5
gr********@gmail.com wrote:
I try this but the results are the same...
Maybe because ...
Any other ideas?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html>

<head>

<script>
.... it's not Valid HTML 4.01. <http://validator.w3.org/>
function showGeneralEdit(show) {
if (show) {
document.getElementById("GeneralEdit").style.displ ay = "";
document.getElementById("GeneralStatic").style.dis play = "none";
} else {
document.getElementById("GeneralEdit").style.displ ay = "none";
document.getElementById("GeneralStatic").style.dis play = "";
}
}
You access either element in both cases, so you should at least compact to

function showGeneralEdit(show)
{
var
oGE = document.getElementById("GeneralEdit"),
oGS = document.getElementById("GeneralStatic");

if (show)
{
oGE.style.display = "";
oGS.style.display = "none"
}
else
{
oGE.style.display = "none";
oGS.style.display = "";
}
}

This of course leaves the task of performing proper feature tests
on properties before, see <http://pointedears.de/scripts/test/whatami> ff.

<style>


Where's the type attribute and it's value?
PointedEars
--
This above all: To thine own self be true.
-- William Shakespeare (1564-1616)
Oct 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Egon Pasztor | last post by:
Hi. I'm new at CSS, so maybe this is obvious, but I've looked around quite a bit looking for a solution. I'm playing with the vertical positioning of elements in a 2-column layout. The...
5
by: mt | last post by:
In a nutshell, I'd like to have a list of items, each of which fills out a small table which displays some info about a particular item(the items being a trouble ticket for a tech support ASP-built...
9
by: middletree | last post by:
I'm doing an ASP-built Intranet app, and am having trouble with a bit of code on the menu I am using. I got it from some free site, but I tried emailing the person whose email address is in the...
39
by: WindAndWaves | last post by:
Hi Gurus I have a page, which looks a bit like this: .... <body> <div ID=id1>................</DIV> <div ID=gsd>................</DIV> <div ID=ewd>................</DIV> <div...
2
by: c.anandkumar | last post by:
Hi All - I have some problems getting a small piece of javascript working correctly for Firefox. Here is what I am trying to do - 1. I have a form (like a search form) 2. I have many groups...
12
by: meltedown | last post by:
I would like the floating divs to float and then the header to come after them , on the left. That's what I thought clearing the floats was for, but in this example, the header is to the right of...
2
by: tasman.hayes | last post by:
I'm experimenting with converting a site from a table layout to CSS. I'm floating three DIVs in a row for the top of a website (a logo, navigation buttons and a email list signup box). The DIVs...
24
by: Kourosh | last post by:
I have a lot of DIV tags on an HTML page. I want to group some of them so that I can hide them all together at once if needed. What's a good way to do this? I want this to be compatible with at...
7
by: zenbob | last post by:
Greetings, and thanks in advance for considering my problem. I am working in a basic .htm page, in which I want to close all displayed DIVs with one event. In IE, I find that this works: ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.