473,385 Members | 1,834 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,385 software developers and data experts.

FireFox, RemoveChild, AppendChild, making width grow?

Originally posted in comp.lang.javascript:

Newsgroups: comp.lang.javascript
From: "Stewart"
Date: 23 Aug 2005 02:50:04 -0700
Local: Tues, Aug 23 2005 10:50 am
Subject: FireFox, RemoveChild, AppendChild, making width grow?
Hi,
I have a div with a table under it. I'm using the DOM to change that
table dynamically. But when I run it under FireFox, it makes the div
holding the table grow width-ways. The div itself has no assigned
width, although it is inside a td which has a % width set.
I experimented with removing and appending the same table, to prove it
was nothing to do with the data, and sure enough, the div still grows!
I have run out of ideas as to how to debug or fix this. Anyone shed any

light?
Example code (for making your div get wider) is:
var toc = document.getElementById('toc')*;
var tables = toc.getElementsByTagName('tabl*e');
var tmp = toc.removeChild(tables[0]);
toc.appendChild(tmp);
Stewart

Newsgroups: comp.lang.javascript
From: "Stewart"
Date: 23 Aug 2005 03:06:44 -0700
Local: Tues, Aug 23 2005 11:06 am
Subject: Re: FireFox, RemoveChild, AppendChild, making width grow?
OK, I found a hack, ugly as it is:
I experimented with width properties of the div.
By having:
toc.style.width = '99%';
after the appendChild, at the end, the div doesn't grow.
Note that:
toc.style.width = '100%';
does allow the growing width.


Newsgroups: comp.lang.javascript
From: RobG
Date: Wed, 24 Aug 2005 02:59:17 GMT
Local: Wed, Aug 24 2005 3:59 am
Subject: Re: FireFox, RemoveChild, AppendChild, making width grow?

Stewart wrote:
OK, I found a hack, ugly as it is: I experimented with width properties of the div.
By having:
toc.style.width = '99%';
after the appendChild, at the end, the div doesn't grow.
Note that:
toc.style.width = '100%';
does allow the growing width.
There is more to this than you are letting on. The following test does

not exhibit your 'growing' behaviour.

<script type="text/JavaScript">
function doStuff(){
var toc = document.getElementById('toc')*;
var tables = toc.getElementsByTagName('tabl*e');
var tmp = toc.removeChild(tables[0]);
alert('hey'); // just to show that the table is removed & replaced
toc.appendChild(tmp);
}
</script>
<input type="button" value="do stuff" onclick="doStuff()">
<table><tr><td style="width: 50%;">
<div id="toc" style="border: 1px solid green; width: 100%;">
<table border="1">
<tr>
<td>This is the table</td>
<td>This is the table</td>
</tr>
<tr>
<td>This is the table</td>
<td>This is the table</td>
</tr>
</table>
</div>
</td></tr></table>

--
Rob

Newsgroups: comp.lang.javascript
From: "Stewart"
Date: 24 Aug 2005 07:01:10 -0700
Local: Wed, Aug 24 2005 3:01 pm
Subject: Re: FireFox, RemoveChild, AppendChild, making width grow?

Rob,
You are absolutely correct. Your script does not reproduce this.
I took your script and added to and modified it based on my page, until

it did reproduce the error, and then through trial & error isolated the

minimum needed to this.
I found it's down to the CSS: specifically, having overflow:auto and
width set for the div tag.
This script does produce the growing width effect:
<html>
<head>
<style type="text/css" media="all">
div#toc
{
border: 1px solid green;
overflow: auto;
width: 100%;
}
</style>
<script type="text/JavaScript">
function doStuff(){
var toc = document.getElementById('toc')*;
var tables = toc.getElementsByTagName('tabl*e');
var tmp = toc.removeChild(tables[0]);
//alert('hey'); // just to show that the table is removed &
replaced
toc.appendChild(tmp);

}
</script>
</head>
<body>
<input type="button" value="do stuff" onclick="doStuff()">
<table>
<tr>
<td style="width: 50%;">
<div id="toc">
<table> <tr> <td>
LHS
</td> </tr> </table>
</div>
</td>
<td style="width: 50%;">RHS</td>
</tr>
</table>
</body>
</html>

Stewart


Newsgroups: comp.lang.javascript
From: "Stewart"
Date: 24 Aug 2005 07:06:44 -0700
Local: Wed, Aug 24 2005 3:06 pm
Subject: Re: FireFox, RemoveChild, AppendChild, making width grow?
However, bizarrely enough, I have to add:
toc.style.width = '95%';
to prevent the growth with a hack, on this script.
Values of 96% or greater allow the growth.
Maybe this is something to do with margins and padding?


Newsgroups: comp.lang.javascript
From: RobG
Date: Thu, 25 Aug 2005 01:07:32 GMT
Local: Thurs, Aug 25 2005 2:07 am
Subject: Re: FireFox, RemoveChild, AppendChild, making width grow?


Stewart wrote: However, bizarrely enough, I have to add:
toc.style.width = '95%';
to prevent the growth with a hack, on this script.
Values of 96% or greater allow the growth. Maybe this is something to do with margins and padding?


Hmm, you could ask in a CSS or HTML forum such as:

comp.infosystems.www.authoring.html
or
comp.infosystems.www.authoring.css
--
Rob

Aug 25 '05 #1
2 5217
My apologies to Mozilla FireFox.

I've discovered this only happens in Netscape 8 when rendering "like
FireFox".

Stewart

Aug 25 '05 #2
My apologies to Mozilla FireFox.

I've discovered this only happens in Netscape 8 when rendering "like
FireFox".

Stewart

Aug 25 '05 #3

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

Similar topics

4
by: Oscar Monteiro | last post by:
the Code below captures the Mouse move event, while event isnīt defined anywhere it still works in IE only, how can I define the event handler so it can work with other browsers, Firefox mostly....
24
by: Robi | last post by:
I have the following problem: I populate a page with a specific amount of <div id="MyTest"> containers inside another <div> container. for (i=0; i < MyString.length; i++) document.write('<div...
2
by: Stewart | last post by:
Originally posted in comp.lang.javascript: Newsgroups: comp.lang.javascript From: "Stewart" Date: 23 Aug 2005 02:50:04 -0700 Local: Tues, Aug 23 2005 10:50 am Subject: FireFox, RemoveChild,...
2
by: ranger7419 | last post by:
I'm trying to figure out why this script will work in IE 6 but not Firefox, and so I need someone here with a far better grasp on javascript to explain this. Basically, I have a page with several...
5
by: juergen.riemer | last post by:
Hi, following code does not render scrollbars in firefox 1.5.x. Bug? Workaround other than to innerHTML an absolute positioned element after loading? <html> <body> <div...
1
by: apog | last post by:
Hello, everyone! I have a javascript running perfectly with IE, but nothing seems to happend if I use firefox... anyone knows why? Here is the script: function add_div_field () { var ni =...
6
by: ApOG | last post by:
Hello everyone, I have this javascript code working perfectly with IE, but with firefox nothing happens when running the function... function add_div_field () { var ni =...
1
by: bumpy | last post by:
I wrote this pretty slick DHTML table that lets you add/remove rows and show/hide columns on the fly. It works perfectly in IE7, but it doesn't behave in Firefox 2.0.0.4. You can see it in action...
1
by: PETERMCHARRIS | last post by:
This code works in IE (pops up the div) but not in firefox, I cannot see why, any ideas? function creatediv(id, html, width, height, left, top) { if (document.getElementById(id) != null) { ...
4
by: Patrick Nolan | last post by:
I am using javascript to manipulate optgroups in select elements. When the results are displayed in Firefox 2.0 there is an annoying blank line at the top of the multi-line select box. This...
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
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.