473,396 Members | 2,026 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,396 software developers and data experts.

deleteRow causes Netscape 7 to crash - why ?

Dom
Hi,

I am trying to get a dynamic table going. You click a button to add a
row. In the newly created row a button to delete the row is placed
(try the code example below). In Netscape, pressing the delete row
button crashes the browser. Why ? What is the correct way to do this ?

I am stumped why this following code works in IE and Opera but crashes
Netscape 7 (ie makes it disappear and try to send a bug report etc).

Any help would be much appreciated.

Copy and save the following code example and try running in Netscape 7
(or Mozilla 1.4) . It works fine in IE 6 and Opera 7. I've tried all
sorts of tweaking around but to no avail.

I need some expert help. Perhaps suggest the correct or other better
way of implementing this.
Here's the code:

<html><head>

<script language="javascript">

function createTableRow(oTable)
{
var thetable = document.all ? document.all[oTable] :
document.getElementById(oTable); // get table object handle
var nrows=thetable.rows.length; // get current tablesize
var row = thetable.insertRow(nrows); // create a new row object
var cell ;

cell = row.insertCell(0); cell.innerHTML="row"+nrows; // create a new
cell in the new row

// this will crash my netscape 7.2 browser but works fine in Opera
and IE
cell = row.insertCell(1); cell.innerHTML="<button
onclick='deleteTableRow(this.parentNode.parentNode .rowIndex)'>Delete</button>";

// This will behave strangely in that it will remove ALL rows from
the table - why ??? again, it works in Opera and IE.
//cell = row.insertCell(1); cell.innerHTML="<button
onclick='deleteTableRow(0)'>Delete</button>";
}

function deleteTableRow(nth)
{
var thetable = document.all ? document.all['tbl'] :
document.getElementById('tbl'); // get the tbl table object handle
thetable.deleteRow(nth); // delete the nth row from the table ####
this crashes Netscape 7 and 6 - WHY ????
}
</script>
<body bgcolor=white>
<form name="form1" method="post" action=""
enctype="multipart/form-data" >
<table border=1 width="232">
<!--col width=150><col width=150><col width=80-->
<tr><th>Name</th><th>Qty</th></tr>
</table>

<table id='tbl' border=1>
<col width=150><col width=150><col width=80>
<!-- TABLE for the order items -->
</table>

<input TYPE="button" VALUE="Add Item"
onclick="createTableRow('tbl')">
<input type="submit" name="Submit" value="Submit" >

</form></body></html>
Jul 20 '05 #1
2 3043
DU
Dom wrote:
Hi,

I am trying to get a dynamic table going. You click a button to add a
row. In the newly created row a button to delete the row is placed
(try the code example below). In Netscape, pressing the delete row
button crashes the browser. Why ? What is the correct way to do this ?

I am stumped why this following code works in IE and Opera but crashes
Netscape 7 (ie makes it disappear and try to send a bug report etc).

Any help would be much appreciated.

Copy and save the following code example and try running in Netscape 7
(or Mozilla 1.4) . It works fine in IE 6 and Opera 7. I've tried all
sorts of tweaking around but to no avail.

I need some expert help. Perhaps suggest the correct or other better
way of implementing this.
Here's the code:

<html><head>

<script language="javascript">

function createTableRow(oTable)
{
var thetable = document.all ? document.all[oTable] :
document.getElementById(oTable); // get table object handle
Since the rest of the function can not be executed by MSIE 4, then there
is no point to branch the code in the above instruction.
var nrows=thetable.rows.length; // get current tablesize
var row = thetable.insertRow(nrows); // create a new row object
var cell ;

cell = row.insertCell(0); cell.innerHTML="row"+nrows; // create a new
cell in the new row

// this will crash my netscape 7.2 browser
we're still at NS 7.1 :)
but works fine in Opera and IE
cell = row.insertCell(1); cell.innerHTML="<button
onclick='deleteTableRow(this.parentNode.parentNode .rowIndex)'>Delete</button>";
I tried a few modifications of the above instruction and nevertheless,
NS 7.1 always crashed. You might have found an old - but rare - crash
bug here ... since the code works and does not crash in Opera 7.2 and
Mozilla 1.5RC2

// This will behave strangely in that it will remove ALL rows from
the table - why ??? again, it works in Opera and IE.
//cell = row.insertCell(1); cell.innerHTML="<button
onclick='deleteTableRow(0)'>Delete</button>";
}

function deleteTableRow(nth)
{
var thetable = document.all ? document.all['tbl'] :
document.getElementById('tbl'); // get the tbl table object handle
thetable.deleteRow(nth); // delete the nth row from the table ####
this crashes Netscape 7 and 6 - WHY ????
}
This deleteTableRow function could be safely removed and replaced entirely.
</script>
<body bgcolor=white>
<form name="form1" method="post" action=""
enctype="multipart/form-data" >
<table border=1 width="232">
<!--col width=150><col width=150><col width=80-->
<tr><th>Name</th><th>Qty</th></tr>
</table>

<table id='tbl' border=1>
<col width=150><col width=150><col width=80>
<!-- TABLE for the order items -->
</table>

<input TYPE="button" VALUE="Add Item"
onclick="createTableRow('tbl')">
<input type="submit" name="Submit" value="Submit" >

</form></body></html>

Your code could be optimized and be made much more compact at several
places. Your code works in Mozilla 1.5RC2 but it crashes in NS 7.1.
I would avoid resorting to innerHTML everywhere all the time and only
use DOM 2 methods. Here, with DHTML modifying the page, such coding
policy is even more true and recommendable.

In your code, your table "tb1" has 3 columns but each new row only has 2
cells (without any column span).
Despite several efforts, I could not come up with a solution which would
work in NS 7.1.

DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/
- Resources, help and tips for Netscape 7.x users and Composer
- Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x
http://www10.brinkster.com/doctorunc...e7Section.html

Jul 20 '05 #2
"DU" <dr*******@hot-R-E-M-O-V-E-mail.com> wrote in message
news:bm**********@news.eusc.inter.net...
<snip>
I tried a few modifications of the above instruction and
nevertheless, NS 7.1 always crashed. You might have found
an old - but rare - crash bug here ... since the code works
and does not crash in Opera 7.2 and Mozilla 1.5RC2

<snip>

I could not get Netscape 7.02 to crash but I did get Mozilla 1.3 to
crash so I tested in that until it worked (at my first alteration).

The button element that is being written into the HTML has no type
attribute so the HTML 4 specification requires it to default to
type="submit". Obviously submitting a form while simultaneously deleting
it's submit button is a bit much for Mozilla 1.3 so it crashes. Adding a
type="button" attribute solved the problem.

(Another example of how understanding what represents valid HTML and its
meaning would have avoided JavaScript errors ;-)

Richard.
Jul 20 '05 #3

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

Similar topics

2
by: John Geddes | last post by:
In both IE6 and Netscape 7: insertRow method of tbody is behaving as expected: - inserts a new row - increases tbody.rows.length BUT deleteRow is not doing the opposite. It DOES delete the...
7
by: Jonas Smithson | last post by:
Hello all, I have an absolute positioned parent div, and nested inside it is an absolute positioned child div -- I mean the div *code* is nested inside, but the child is physically positioned so...
10
by: Alex Vinokur | last post by:
GNU g++ 3.3.3, Cygwin // Stuff static char* mbuffer = NULL; // Stuff void doit()
1
by: John C | last post by:
Importing DBase files I get to the screen titled "Select Source Table and Views" And none appear in the list. (I can get the list displayed about once in ten tries) From that screen anything causes...
13
by: M B HONG 20 | last post by:
Hi all - I have a .NET web service running on a remote machine, and I have Netscape Navigator 7.0 accessing it through javascript on the client side through SOAP javascript coding. Everything...
18
by: Simula | last post by:
I am developing an HTML javascript application and I want to preserve state in a way that can be book-marked. I chose HTML anchors as a means of preserving state. When the application changes...
8
by: Adam Louis | last post by:
I would like help resolving this problem. I'm a novice who's been hired to query a hospital database and extract useful information, available to me only in a dynamically generated, downloadable...
2
by: Composer | last post by:
One form in my Access 2000 mdb causes a crash whenever I close it. The crash is of the type where I get a "Please tell Microsoft about this problem". Easy, you think! Well, here are the things...
4
by: jamescostello | last post by:
The code below is part of a script that is imported by a webpage. I am trying to modify a table on that webpage using this code. I can't modify the actual webpage itself. I would like to simply...
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: 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
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.