Click to See Complete Forum and Search --> : Netscape Compatibility


Newcomer19
07-16-2003, 03:29 PM
I need some help with the following code.

This script generates a scrollable list of items and works fine in IE. However there are two problems:

1. Once it reaches the end of the array, I use an alert to indicate end of file. Is there a way to make the scrolling stop when it reaches end of file and it just displays the last set of files?

2. Is there a simple enough way to make it work in Netscape 4+
I know Netscape does not support innerHTML.

Please help me.

==============================================
<table cellspacing="0" cellpadding="1" width="100%" bgcolor="#ffffff" border="0">
<tr><td width="100%">
<div id="oTableContainer"></div>
<script>
var direction=0;
var nextS=0;
var displayPerPage=5;
var myArray = new Array();

function fileMess(item1,item2,item3,item4,item5) {
this.item1 = item1;
this.item2 = item2;
this.item3 = item3;
this.item4 = item4;
this.item5 = item5;
myArray[myArray.length] = this;
}

function createfileMess() {
new fileMess("101","blah101","101","0","");
new fileMess("102","blah102","102","0","");
new fileMess("103","blah103","103","0","");
new fileMess("104","blah104","104","1","");
new fileMess("105","blah105","105","1","");
new fileMess("106","blah106","106","1","");
new fileMess("107","blah107","107","1","");
new fileMess("108","blah108","108","1","");
new fileMess("109","blah109","109","1","");
new fileMess("110","blah110","110","1","");
new fileMess("111","blah111","111","1","");
new fileMess("112","blah112","112","1","");
new fileMess("113","blah113","113","1","");
new fileMess("114","blah114","114","1","");
new fileMess("115","blah115","115","1","");
new fileMess("116","blah116","116","1","");
new fileMess("117","blah117","117","1","");
new fileMess("118","blah118","118","1","");
new fileMess("119","blah119","119","1","");
new fileMess("120","blah120","120","1","");
}

function displayfileMess(s)
{
var oTable = document.createElement("TABLE");
var oTHead = document.createElement("THEAD");
var oTBody0 = document.createElement("TBODY");
var oTBody1 = document.createElement("TBODY");
var oTFoot = document.createElement("TFOOT");
var oCaption = document.createElement("CAPTION");
var oRow, oCell;
var i, j;

var heading = new Array;

heading[0] = "item1";
heading[1] = "item2";
heading[2] = "item3";
heading[3] = "item4";
heading[4] = "item5";

// Insert the created elements into oTable.
oTable.appendChild(oTHead);
oTable.appendChild(oTBody0);
oTable.appendChild(oTBody1);
oTable.appendChild(oTFoot);
oTable.appendChild(oCaption);

// Set the table's border width and colors.
oTable.border=0;
oTable.bgColor="cccccc";
oTable.width="396";

oRow = document.createElement("TR");
oTHead.appendChild(oRow);
oTHead.bgColor = "cccccc";

// Create and insert cells into the header row.
for (i=0; i<5; i++)
{
oCell = document.createElement("TH");
oCell.innerText = heading[i];
oRow.appendChild(oCell);
}

// Create and insert rows and cells into the first body.
direction = s;
if (direction ==-1)
{
nextS = nextS-displayPerPage;
}
if (direction ==1){
nextS = nextS+displayPerPage;
}
if (nextS <=-displayPerPage)
{
nextS =0;
}
f=nextS+displayPerPage;
if (f>myArray.length)
{
f=myArray.length;
alert("end of files");
}
for (i=nextS; i<f; i++)
{
oRow = document.createElement("TR");
oTBody0.appendChild(oRow);

{
oCell = document.createElement("TD");
oCell.innerText = myArray[i].item1;
oRow.appendChild(oCell);
oCell = document.createElement("TD");
oCell.innerText = myArray[i].item2;
oRow.appendChild(oCell);
oCell = document.createElement("TD");
oCell.innerText = myArray[i].item3;
oRow.appendChild(oCell);
oCell = document.createElement("TD");
oCell.innerText = myArray[i].item4;
oRow.appendChild(oCell);
oCell = document.createElement("TD");
oCell.innerText = myArray[i].item5;
oRow.appendChild(oCell);
}
s=0;
}
// Insert the table into the document tree.
oTableContainer.appendChild(oTable);
}
createfileMess();
displayfileMess();
document.write("<table width=350><tr><td><input type=button value=previous onClick='oTableContainer.innerHTML=\"\"; displayfileMess(-1)'><input type=button value=next onClick='oTableContainer.innerHTML=\"\"; displayfileMess(1)'></td></tr></table>");
</script>
</td></tr></table>

Khalid Ali
07-16-2003, 05:37 PM
this doesnt seem to be the all code thats required..I don't see any scrolling code..or may be me going blind..:p

Newcomer19
07-16-2003, 08:20 PM
Hi Khalid,

Allow me to correct my wordings, this script actually loads items from an array into a table. Its not scrolling per se. The main problem is with the usage of innerHTML. Is there a workaround for Netscape with this issue?

Many thanks.

Khalid Ali
07-16-2003, 08:46 PM
dor NN<5 you will have to use this format

document.layerId.document.open();
document.layerId.document.write(yourData);
document.layerId.document.close();

Newcomer19
07-17-2003, 10:19 AM
Khalid,

I tried to use document.layerId in the code but it still does not work. Could you please trouble shoot this for me and tell me where I am going wrong?

Please let me know..

Many thanks,

==========================================


<html>
<body>
<table cellspacing="0" cellpadding="1" width="100%" bgcolor="#ffffff" border="1">
<tr><td width="100%">
<div id="Container"></div>
<script>
var direction=0;
var nextS=0;
var displayPerPage=5;
var myArray = new Array();

function etcList(item1,item2,item3,item4,item5) {
this.item1 = item1;
this.item2 = item2;
this.item3 = item3;
this.item4 = item4;
this.item5 = item5;
myArray[myArray.length] = this;
}

function createetcList() {
new etcList("101","blah101","101","0","");
new etcList("102","blah102","102","0","");
new etcList("103","blah103","103","0","");
new etcList("104","blah104","104","1","");
new etcList("105","blah105","105","1","");
new etcList("106","blah106","106","1","");
new etcList("107","blah107","107","1","");
new etcList("108","blah108","108","1","");
new etcList("109","blah109","109","1","");
new etcList("110","blah110","110","1","");
new etcList("111","blah111","111","1","");
new etcList("112","blah112","112","1","");
new etcList("113","blah113","113","1","");
new etcList("114","blah114","114","1","");
new etcList("115","blah115","115","1","");
new etcList("116","blah116","116","1","");
new etcList("117","blah117","117","1","");
new etcList("118","blah118","118","1","");
new etcList("119","blah119","119","1","");
new etcList("120","blah120","120","1","");
}

function displayetcList(s)
{
var oTable = document.layerId.document.createElement("TABLE");
var oTHead = document.layerId.document.createElement("THEAD");
var oTBody0 = document.layerId.document.createElement("TBODY");
var oTBody1 = document.layerId.document.createElement("TBODY");
var oTFoot = document.layerId.document.createElement("TFOOT");
var oCaption = document.layerId.document.createElement("CAPTION");
var oRow, oCell;
var i, j;

var heading = new Array;

heading[0] = "item1";
heading[1] = "item2";
heading[2] = "item3";
heading[3] = "item4";
heading[4] = "item5";

// Insert the created elements into oTable.
oTable.appendChild(oTHead);
oTable.appendChild(oTBody0);
oTable.appendChild(oTBody1);
oTable.appendChild(oTFoot);
oTable.appendChild(oCaption);

// Set the table's border width and colors.
oTable.border=0;
oTable.bgColor="cccccc";
oTable.width="396";

oRow = document.layerId.document.createElement("TR");
oTHead.appendChild(oRow);
oTHead.bgColor = "cccccc";

// Create and insert cells into the header row.
for (i=0; i<5; i++)
{
oCell = document.layerId.document.createElement("TH");
oCell.innerText = heading[i];
oRow.appendChild(oCell);
}

// Create and insert rows and cells into the first body.
direction = s;
if (direction ==-1)
{
nextS = nextS-displayPerPage;
}
if (direction ==1){
nextS = nextS+displayPerPage;
}
if (nextS <=-displayPerPage)
{
nextS =0;
}
f=nextS+displayPerPage;
if (f>myArray.length)
{
f=myArray.length;
alert("end of files");
}
for (i=nextS; i<f; i++)
{
oRow = document.layerId.document.createElement("TR");
oTBody0.appendChild(oRow);

{
oCell = document.layerId.document.createElement("TD");
oCell.innerText = myArray[i].item1;
oRow.appendChild(oCell);
oCell = document.layerId.document.createElement("TD");
oCell.innerText = myArray[i].item2;
oRow.appendChild(oCell);
oCell = document.layerId.document.createElement("TD");
oCell.innerText = myArray[i].item3;
oRow.appendChild(oCell);
oCell = document.layerId.document.createElement("TD");
oCell.innerText = myArray[i].item4;
oRow.appendChild(oCell);
oCell = document.layerId.document.createElement("TD");
oCell.innerText = myArray[i].item5;
oRow.appendChild(oCell);
}
s=0;
}
// Insert the table into the document tree.
Container.appendChild(oTable);
}
createetcList();
displayetcList();
</script>
</td></tr>
<tr><td>
<script language="javascript">document.write("<table width=350 height=200><tr><td><input type=button value=previous onClick='document.layerId.Container.innerHTML=\"\"; displayetcList(-1)'><input type=button value=next onClick='document.layerId.Container.innerHTML=\"\"; displayetcList(1)'></td></tr></table>");
</script>
</td></tr></table>
</body>
</html>

gil davis
07-18-2003, 07:48 AM
NS 4.x does not support createElement(), among other things. You are trying to use W3 DOM procedures on a non-compliant browser.

If you are serious about making your code compatible with N 4, I suggest you start with http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/. and see what it *does* support.