473,387 Members | 1,492 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.

Work with Netscape/Modzilla but not IE. Why?

This function works as intended with Netscape/Modzilla.
But, it doesn't work with IE version 6.0.2900.2180.xpsp_sp2_rtm040803-2158.
Can someone tell me how to fix it?

Thanks.

function change_cell(y,x,my_piece)
{
var xx=0;
xx=x+1;
if (document.getElementById) {
var rowRef = document.getElementById(r);
} else if (document.all) {
var rowRef = document.all[r];
}
var theCells=document.getElementById('my_table').rows[y].cells;

if (!theCells[0]) theCells = rowRef.childNodes;
var r=document.getElementById('my_table').rows[y].cells;
while (r[xx].childNodes.length > 0)
r[xx].removeChild(r[xx].childNodes[0]);
var spanNode = document.createElement('img');
spanNode.src=my_piece;
spanNode.width=wl;
spanNode.height=wl;
r[xx].appendChild(spanNode);
}
Jul 23 '05 #1
2 1398
Better but still clumpsy wrote:
This function works as intended with Netscape/Modzilla.
But, it doesn't work with IE version 6.0.2900.2180.xpsp_sp2_rtm040803-2158.
Can someone tell me how to fix it?
I'm surprised it 'works' at all. I can only guess at the HTML
associated with this, you should have provided a minimal snippet
to help out. Anyhow, here's my guess.

Thanks.

function change_cell(y,x,my_piece)
{
var xx=0;
xx=x+1;
You appear to be passing a number as 'x', so why not just use
that, and use x wherever you've used xx?

x++;
if (document.getElementById) {
var rowRef = document.getElementById(r);
You have not defined 'r', so this will fail (you declare it
below, so I guess it's not a global you didn't tell us about)
} else if (document.all) {
var rowRef = document.all[r];
}
var theCells=document.getElementById('my_table').rows[y].cells;
'theCells' is a collection of the cells for a row index you
passed to the function - it seems 'my_table' is what r should
have been initialised with before attempting to use it above.

if (!theCells[0]) theCells = rowRef.childNodes;
I guess you are seeing here if the cells collection is supported,
and if not, using the childNodes collection.
var r=document.getElementById('my_table').rows[y].cells;

Now you declare 'r' using gEBI, which you should have done
above...
while (r[xx].childNodes.length > 0)
r[xx].removeChild(r[xx].childNodes[0]);


and proceed to ignore all the work you did getting 'theCells'.

[...]

As far as I can see, you are attempting to replace the image in
an adjacent table cell. If that's what you want to do, try
this (lightly tested in Firefox and IE6):

<script type="text/javascript">
function changeCell(c){
// c is a reference to the cell clicked on
// Get the adjacent cell
var c2 = c.parentNode.cells[c.cellIndex + 1];

// Change the image source
// You could just replace the innerHTML of the cell...
// Or delete all the childNodes and put an img in there...
// But I'll search for an img and replace the src
for (var i=0, c2Len=c2.childNodes.length; i<c2Len; i++){
if (c2.childNodes[i].nodeName.toLowerCase() == 'img'){
c2.childNodes[i].src = '2.gif';
return; // Stop once image replaced
}
}
}
</script>

<table>
<tr>
<td onclick="
changeCell(this);
">aaaaaaaa</td>
<td><img src="1.gif" alt=""></td>
</tr>
<tr>
<td onclick="
changeCell(this);
">bbbbbbbb</td>
<td><img src="1.gif" alt=""></td>
</tr>
</table>
--
Rob
Jul 23 '05 #2
Thanks for pointing out. Getting use to rely on compiler to check for
mistakes and very clumpsy with script. OK, I'd checked and double
checked the modifed display functions as you'd suggested. But, it
is still not working with IE.

I have two types of board(8x8) or (14x14) depending on the number of
players. I delete all rows and create a new ones if the new board differs
from the previous one.

function deleteRow(i)
{
document.getElementById('my_table').deleteRow(i)
}

function maketable()
{
var r,x,y,z,v,c;

for (y=0;y<=YMAX;y++)
{
r=document.getElementById('my_table').insertRow(y) ;
for (x=0;x<=XMAX;x++)
{
z=r.insertCell(x);
if ((y<YMAX) && (x==0))
z.innerHTML=YMAX-y;
if ((y==YMAX) && (x>0))
{
if (x==1)
z.innerHTML='A';else
if (x==2)
z.innerHTML='B';else
if (x==3)
z.innerHTML='C';else
if (x==4)
z.innerHTML='D';else
if (x==5)
z.innerHTML='E';else
if (x==6)
z.innerHTML='F';else
if (x==7)
z.innerHTML='G';else
if (x==8)
z.innerHTML='H';else
if (x==9)
z.innerHTML='I';else
if (x==10)
z.innerHTML='J';else
if (x==11)
z.innerHTML='K';else
if (x==12)
z.innerHTML='L';else
if (x==13)
z.innerHTML='M';else
if (x==14)
z.innerHTML='N';
}
}
}
}

function display_board()
{
var i=8,c2Len;
var j=0;
var k=0;
var v=0;
var r,x,y;

for (y=0;y<=YMAX;y++)
{
for (x=1;x<=XMAX;x++)
{
r=document.getElementById('my_table').rows[y].cells;
v=my_board[x-1][YMAX-y-1];
if (v>=0)
{
for (var i=0, c2Len=r[x].childNodes.length; i<c2Len; i++)
if (r[x].childNodes[i].nodeName.toLowerCase() == 'img')
{
r[x].childNodes[i].src = pieces[v];
return; // Stop once image replaced
}
var spanNode = document.createElement('img');
spanNode.src=pieces[v];
spanNode.width=wl;
spanNode.height=wl;
r[x].appendChild(spanNode);
}
}
}
}

function change_cell(y,x,my_piece)
{
var xx=0,c2Len;

var r=document.getElementById('my_table').rows[y].cells;
for (var i=0, c2Len=r[x].childNodes.length; i<c2Len; i++)
if (r[x].childNodes[i].nodeName.toLowerCase() == 'img')
{
r[x].childNodes[i].src = my_piece;
return;
}
var spanNode = document.createElement('img');
spanNode.src=my_piece;
spanNode.width=wl;
spanNode.height=wl;
r[x].appendChild(spanNode);
}

RobG <rg***@iinet.net.auau> writes:
Better but still clumpsy wrote:
This function works as intended with Netscape/Modzilla.
But, it doesn't work with IE version 6.0.2900.2180.xpsp_sp2_rtm040803-2158.
Can someone tell me how to fix it?


I'm surprised it 'works' at all. I can only guess at the HTML
associated with this, you should have provided a minimal snippet
to help out. Anyhow, here's my guess.
Thanks.
function change_cell(y,x,my_piece)
{
var xx=0;
xx=x+1;


You appear to be passing a number as 'x', so why not just use
that, and use x wherever you've used xx?

x++;
if (document.getElementById) {
var rowRef = document.getElementById(r);


You have not defined 'r', so this will fail (you declare it
below, so I guess it's not a global you didn't tell us about)
} else if (document.all) {
var rowRef = document.all[r];
}
var theCells=document.getElementById('my_table').rows[y].cells;


'theCells' is a collection of the cells for a row index you
passed to the function - it seems 'my_table' is what r should
have been initialised with before attempting to use it above.
if (!theCells[0]) theCells = rowRef.childNodes;


I guess you are seeing here if the cells collection is supported,
and if not, using the childNodes collection.
var r=document.getElementById('my_table').rows[y].cells;

Now you declare 'r' using gEBI, which you should have done
above...
while (r[xx].childNodes.length > 0)
r[xx].removeChild(r[xx].childNodes[0]);


and proceed to ignore all the work you did getting 'theCells'.

[...]

As far as I can see, you are attempting to replace the image in
an adjacent table cell. If that's what you want to do, try
this (lightly tested in Firefox and IE6):

<script type="text/javascript">
function changeCell(c){
// c is a reference to the cell clicked on
// Get the adjacent cell
var c2 = c.parentNode.cells[c.cellIndex + 1];

// Change the image source
// You could just replace the innerHTML of the cell...
// Or delete all the childNodes and put an img in there...
// But I'll search for an img and replace the src
for (var i=0, c2Len=c2.childNodes.length; i<c2Len; i++){
if (c2.childNodes[i].nodeName.toLowerCase() == 'img'){
c2.childNodes[i].src = '2.gif';
return; // Stop once image replaced
}
}
}
</script>

<table>
<tr>
<td onclick="
changeCell(this);
">aaaaaaaa</td>
<td><img src="1.gif" alt=""></td>
</tr>
<tr>
<td onclick="
changeCell(this);
">bbbbbbbb</td>
<td><img src="1.gif" alt=""></td>
</tr>
</table>
--
Rob

Jul 23 '05 #3

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

Similar topics

4
by: Steven Green | last post by:
I did a clean install of Windows XP on my computer and my javascript will not work. I've tried all types of browsers, I've download the Service pack 1 for XP and IE. I have download java from...
2
by: SabMan | last post by:
I understand that document.layers is no longer supported in Netscape 7.1 but I am not sure on how to fix the code so that it will work with Netscape 7.1. I understand that document.all is no...
10
by: Ukiharappa | last post by:
Hello All, I am not sure why. It works on Outlook and other mail clients. I have put it as an include file to the .css instead of putting it inline with the html email. Anyody has any ideas...
13
by: AMC | last post by:
Hi, I have the below code in an asp page. When I run this page in IE or Opera it correctly displays the header info and does not redirect me to 'test.html'. However, when I run this in Netscape...
5
by: zaw | last post by:
Hi I am working on implementing this script to shopping cart. Basically, it copies fill the shipping address from billing automatically. I believe one or more syntax is not netscape compatible....
9
by: chandramohan.mani | last post by:
Does Event handlers work in netscape. If yes means can anyone please help me. <HTML><SCRIPT LANGUAGE="JScript"> function mouseclick() { alert("I was clicked on " +...
1
by: Mr. x | last post by:
Hello, I am using the dotnet validators one of them is requiredFieldValidator. Is there any reason, that requiredFieldValidator won't work for Netscape ? (I have netscape 7.0, and it seems...
5
by: raagz | last post by:
Hi, I am using the .NET validation controls for validating . The validation works fine with IE but none of them work with Netscape 6 browser. Do i have to configure something in vS.NET to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
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
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.