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

Why is Safari not inserting a new row/field in the same order like IE, Mozilla and Opera

I'm really very confused. With the following code I can add rows/fields in
frame 1 and 2. If I use IE, Mozilla or Opera the new rows/fields get added
in ascending order. However, if I use Safari the inserted rows/fields in
frame 2 are in descending order (frame 1 is in ascending order).

Is this a bug?
Is this a known problem?
How can I fix this problem?

Stefan
++++++++++++++++++++++++++++++++++++++++++

index.html
==========
<html>
<frameset rows = "*, 20%" frameborder = "0" framespacing = "0">
<frame src="frame1.html" name="frame1" scrolling="auto" noresize>
<frame src="frame2.html" name="frame2" scrolling="no" noresize>
</frameset>
</html>

++++++++++++++++++++++++++++++++++++++++++

frame1.html
===========
<html>
<head>
<script type = "text/javascript">
function newrows(formobjekt) {
tab = document.getElementById("tab1");
row = tab.insertRow(tab.rows.length - 1);

cell = row.insertCell(0);
cell.style.width = "100%";
cell.colSpan = "1";
cell.innerHTML = tab.rows.length;

tab = parent.frame2.document.getElementById("tab2");
row = tab.insertRow(tab.rows.length);

cell = row.insertCell(0);
element = parent.frame2.document.createElement("input");
element.type = "text";
element.value = tab.rows.length;
cell.appendChild(element);
}
</script>
</head>

<body>
<form name = "form1" action = "" method = "post" accept-charset =
"iso-8859-1">
<input type = "button" name = "button1" value = "newrows" onClick =
"newrows(document.form1)">

<table id = "tab1" width = "100%" border = "0">
<tr>
<td width = "100%" colspan = "1">
New rows should be added below
</td>
</tr>

<tr>
<td width = "100%" colspan = "1">
New rows should be added before
</td>
</tr>
</table>
</form>
</body>
</html>

++++++++++++++++++++++++++++++++++++++++++

frame2.html
===========
<html>
<body>
<form name = "form2" target = "frame2" action = "" method = "post"
accept-charset = "iso-8859-1">
<table id = "tab2" width = "100%" border = "0">
<tr>
<td>
<input type = "text" name = "field2" style = "width:300px"
value = "New fields should be added below">
</td>
</tr>
</table>
</form>
</body>
</html>
Nov 26 '05 #1
8 2252
Stefan Mueller wrote:
I'm really very confused. With the following code I can
add rows/fields in frame 1 and 2. If I use IE, Mozilla
or Opera the new rows/fields get added in ascending order.
However, if I use Safari the inserted rows/fields in frame
2 are in descending order (frame 1 is in ascending order).
The most probably explanation is that Safari is not updating the length
of the table's - rows - collection as you add rows to the table.
Is this a bug?
Almost certanly.
Is this a known problem?
Probably.
How can I fix this problem?

<snip>

First identify the cause of problem. Try alerting the length of the rows
collection before and after adding rows to see if it changes. Then see
if collections such as the TBODY's childNodes collection change length,
as that might do as an alternative to rows. Otherwise you can keep track
of the number of rows added yourself (i.e. record the start length prior
to the first addition and increment that value as you add rows (assuming
I am right about the cause)).

Richard.
Nov 26 '05 #2
> The most probably explanation is that Safari is not updating the length
of the table's - rows - collection as you add rows to the table.
According to the output (displayed value in the inserted row/field) the
length of the table gets updated.

First identify the cause of problem. Try alerting the length of the rows
collection before and after adding rows to see if it changes.


You're right. But my problem is, that I don't have Safari.
I'm just surprised why it's working in frame 1 different than in frame 2
(only with Safari)

Stefan
Nov 26 '05 #3
On 2005-11-26, Stefan Mueller <se**************@yahoo.com> wrote:
I'm really very confused. With the following code I can add rows/fields in
frame 1 and 2. If I use IE, Mozilla or Opera the new rows/fields get added
in ascending order. However, if I use Safari the inserted rows/fields in
frame 2 are in descending order (frame 1 is in ascending order).
First, fix your html. <tr>s should be children of a <tbody> (etc)
Is this a bug?
I'm not sure.
Is this a known problem?
yes.
How can I fix this problem?


don't use insertRow. use appendChild on the <tbody>

--

Bye.
Jasen
Nov 27 '05 #4
>> First identify the cause of problem. Try alerting the length of the rows
collection before and after adding rows to see if it changes.


You're right. But my problem is, that I don't have Safari.
I'm just surprised why it's working in frame 1 different than in frame 2
(only with Safari)


Last night I've done quite a lot of testing with my Mac (Safari) colleague.
And we figured out, that the following command in Safari is working wrong
row = tab.insertRow(tab.rows.length);

It's not adding the new row after the last row it's adding the new row
before the first row.

Solutino/workaround:
With HTML define a hidden row and add the new row before the last row
(hidden):
row = tab.insertRow(tab.rows.length - 1);

The command above adds a new row before the last row and this works also
with Safari.

Stefan
Nov 27 '05 #5
Jasen Betts wrote:
On 2005-11-26, Stefan Mueller <se**************@yahoo.com> wrote:
I'm really very confused. With the following code I can add rows/fields
in frame 1 and 2. If I use IE, Mozilla or Opera the new rows/fields get
added in ascending order. However, if I use Safari the inserted
rows/fields in frame 2 are in descending order (frame 1 is in ascending
order).


First, fix your html. <tr>s should be children of a <tbody> (etc)


No, they /can/ be. There is nothing to be fixed in the markup as there is
no requirement:

<URL:http://www.w3.org/TR/html4/struct/tables.html#edef-TABLE>

The (known) issue perhaps is that even if the respective elements are not
included in the source code, HTMLTableSectionElement objects are required
in the DOM tree before HTMLTableRowElement objects can be included as their
children.
PointedEars
Nov 27 '05 #6
VK

Stefan Mueller wrote:
I'm really very confused. With the following code I can add rows/fields in
frame 1 and 2. If I use IE, Mozilla or Opera the new rows/fields get added
in ascending order. However, if I use Safari the inserted rows/fields in
frame 2 are in descending order (frame 1 is in ascending order).

Is this a bug?
Is this a known problem?
How can I fix this problem?

1. First of all you should define <tbody> section in your table (or
best of all - all three <thead>, <tfoot> and <tbody>).
These tags are not necessary for HTML layout but they are required if
you plan to script your table later. Most browsers will create <tbody>
automatically but "some browser" (I just love this term :-) will not.

2. addRow() method takes one argument: the position in the rows array
where you want to add new row. Microsoft who invented this method has
this argument set default to -1 which is the common shortcut for
(array.length-1) - the last array element.

So oTable.oBody.insertRow() really means oTable.oBody.insertRow(-1) and
new row goes to the bottom.

Mozilla got it wrong and set default to 0 so oTable.oBody.insertRow()
would be oTable.oBody.insertRow(0) and new row goes to the top. I
guess they realized their oops rather quickly so despite the method
description on mozilla.org still states that default is 0 but it seems
to act is the default is -1.

I guess Safari stays the biggest retard on the market as usual: it got
it wrong and it does it wrong.

Try first if Safary understands the [last element] shortcut:
oTable.oBody.insertRow(-1)

If not then you have to keep doing what you're already doing.

Nov 27 '05 #7
> Try first if Safary understands the [last element] shortcut:
oTable.oBody.insertRow(-1)


I had very similar problems, and yes, using -1 instead of
table.rows.length seems to fix the problem, and also works in firefox
(haven't tested in IE, but I assume it works there too).

As a bonus, I had similar problems to Safari in opera, and using the -1
seemed to fix the problem there too. Great advice, much appreciated!

Dec 15 '05 #8
VK

rj****@gmail.com wrote:
Try first if Safary understands the [last element] shortcut:
oTable.oBody.insertRow(-1)


I had very similar problems, and yes, using -1 instead of
table.rows.length seems to fix the problem, and also works in firefox
(haven't tested in IE, but I assume it works there too).


Of course it does work - this is IE original method and syntax.

Dec 18 '05 #9

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

Similar topics

13
by: Eddie | last post by:
I need to validate a text input field. I just want to say if user enters 93101 or 93102 or 93103 or 93105 or 93106 or 93107 or 93108 or 93109 or 93110 or 93111 or 93116 or 93117 or 93118 or...
4
by: Els | last post by:
Hi all, Whilst testing other things on www.browsercam.com, I found that some pages with absolute positioned pictures were all messed up in Mac's Opera 6.0 and even worse on Safari 1.0, and...
0
by: The Master | last post by:
Ok I went through and deleted code until I discovered the culprit. I then went back to my original style sheet and removed the CSS declaration that caused the floating to brake in safari 1.2. Once...
5
by: Lachlan Hunt | last post by:
Hi, Can somebody with a mac please check if my website style sheet works reasonably well in Safari, and possibly suggest a fix for any problems? I tried the iCapture website to get a screen...
6
by: Sander Tekelenburg | last post by:
While working on <http://www.lotzofmusic.com/> I ran into some issues with overflow (the decorative fishes). It seems to me the construction is sound, yet Safari ignores the overflow:hidden. At...
2
by: Martin Honnen | last post by:
I was playing around with canvas support in recent Safari, Mozilla and Opera (only version 9 preview) but run into issues with Safari related to the very old DOM Level 0 Image object for preloading...
34
by: Simon Wigzell | last post by:
document...focus() will scroll the form to move the specified text field into view on everything I have tried it with except Safari on the MAC. The form doesn't move. Any work around? Thanks.
16
by: Edward | last post by:
Hi All, I am having huge problems with a very simple dotnet framework web page (www.gbab.net/ztest3.aspx) , it does NOT render correctly under Apple's Safari. The DIV's do not align amd float as...
11
by: Stevo | last post by:
I've been using the unload event for a long time. I have this code, which I've abstracted and made into a stripped down simple test case below, and it works fine on the major browsers (IE5+,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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.