The following is a sample page that quits or stops responding:
<html>
<head>
<script>
var aRecords = new Array();
function Record( sText)
{
this.Text = String(sText);
}
function displayRecord()
{
var sDisp = '<table><tr><td>Text</td><td><input type="button" value="New" onClick="addNewRecord();"></td></tr>';
for( var i=0; i<=aRecords.length-1; i++)
{
sDisp += '<tr><td>' + aRecords[i].Text + '</td><td ></td></tr>';
}
sDisp += '</table>';
document.getElementById("divRecord").innerHTML = sDisp;
}
function addNewRecord()
{
var i;
for( i=0; i<aRecords.length; i++)
{
aRecords[i].Active = false;
}
i = aRecords.length;
aRecords[i] = new Record( "#"+i+".");
displayRecord();
}
</script>
</head>
<body onload="displayRecord()">
<div id="divRecord" style="background-color:#FFFF00;"><div>
</body>
</html>
Workaround 1 applied:
<html>
<head>
<script>
var aRecords = new Array();
function Record( sText)
{
this.Text = String(sText);
}
function displayRecord()
{
var sDisp="";
var i,sRow,sCol;
if(window.event.srcElement.id=="button1")
{
i=aRecords.length-1;
sDisp += aRecords[i].Text
sRow=table1.insertRow();
sCol=sRow.insertCell();
sCol.innerText=aRecords[i].Text;
}
}
function addNewRecord()
{
var i;
for( i=0; i<aRecords.length; i++)
{
aRecords[i].Active = false;
}
i = aRecords.length;
aRecords[i] = new Record( "#"+i+".");
displayRecord();
}
</script>
</head>
<body id=body1>
<div id="divRecord" style="background-color:#FFFF00;">
<table id=table1><tr><td>Text</td><td>
<input type="button" value="New" onClick="addNewRecord()" id=button1 name=button1>
</td></tr></table><div>
</body>
</html>
Workaround 2 applied:
Replace the following line in
displayRecord() function of the sample page:
<input type="button" value="New" onClick="addNewRecord();">
with:
<button name="button" onClick="addNewRecord();">New</button>