473,583 Members | 3,155 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

script doesn't work in firefox:Error: obj.cells has no properties.

Hi,

I have a script here which will loop thru a table and check for it's
background color.

But it doesn't work on Firefox. The Error Inspector said "ERROR. obj.cells
has no properties

How should I work around it to ensure it works for IE and FF?

Thanks

function getselected()
{
var obj;
obj = document.getEle mentById('t1');
var cellsarr = new Array();
var chosenarr = new Array();
for(var i = 0; i<obj.cells.len gth;i++)
{
cellsarr[cellsarr.length]=obj.cells[i];
if(obj.cells[i].getAttribute(' bgColor')=='#00 0000')
{
alert(obj.cells[i].id);
}
}

alert(cellsarr. length);

}

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Feb 4 '07 #1
3 2002
Eric Layman wrote:
Hi,

I have a script here which will loop thru a table and check for it's
background color.

But it doesn't work on Firefox. The Error Inspector said "ERROR. obj.cells
has no properties
That would indicate that obj.cells has no properties, i.e. it isn't an
object.
>
How should I work around it to ensure it works for IE and FF?

Thanks

function getselected()
{
var obj;
obj = document.getEle mentById('t1');
What is obj now?

var cellsarr = new Array();
var chosenarr = new Array();
for(var i = 0; i<obj.cells.len gth;i++)
The only W3C DOM object that has a cells property is one that implements
the HTMLTableRowEle ment interface. If obj isn't a table row element,
it will only have a cells property if you gave it one.

I'll guess that obj is a reference to a table. If you want to loop over
all the cells in a table, you'll have to loop over the rows first,
something like:

var rows = obj.rows;
var cell, cells;
for (var i=0, len=rows.length ; i<len; i++){
cells = row[i].cells;
for (var j=0, len2=cells.leng th; j<len; j++){
cell = cells[i];
/* do stuff with each cell */
}
}

{
cellsarr[cellsarr.length]=obj.cells[i];
Consider:

cellsarr[i]=obj.cells[i];
--
Rob
Feb 4 '07 #2

"RobG" <rg***@iinet.ne t.auwrote in message
news:45******** *************** @per-qv1-newsreader-01.iinet.net.au ...
Eric Layman wrote:
>Hi,

I have a script here which will loop thru a table and check for it's
background color.

But it doesn't work on Firefox. The Error Inspector said "ERROR.
obj.cells has no properties

That would indicate that obj.cells has no properties, i.e. it isn't an
object.
>>
How should I work around it to ensure it works for IE and FF?

Thanks

function getselected()
{
var obj;
obj = document.getEle mentById('t1');

What is obj now?

> var cellsarr = new Array();
var chosenarr = new Array();
for(var i = 0; i<obj.cells.len gth;i++)

The only W3C DOM object that has a cells property is one that implements
the HTMLTableRowEle ment interface. If obj isn't a table row element, it
will only have a cells property if you gave it one.

I'll guess that obj is a reference to a table. If you want to loop over
all the cells in a table, you'll have to loop over the rows first,
something like:

var rows = obj.rows;
var cell, cells;
for (var i=0, len=rows.length ; i<len; i++){
cells = row[i].cells;
for (var j=0, len2=cells.leng th; j<len; j++){
cell = cells[i];
/* do stuff with each cell */
}
}

> {
cellsarr[cellsarr.length]=obj.cells[i];

Consider:

cellsarr[i]=obj.cells[i];
--
Rob
Thanks Rob! Finally got it to work wif FF.

This shows that IE do not follow W3C recommendations ?

But your inner for loop should read as

for (var j=0, len2=cells.leng th; j<len2; j++)

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Feb 4 '07 #3
On Feb 5, 10:35 am, "Eric Layman" <erricson@laysw rote:
[...]
Thanks Rob! Finally got it to work wif FF.

This shows that IE do not follow W3C recommendations ?
Something of an understatement ;-) but there is nothting that says a
table can't have a cells collection too.
>
But your inner for loop should read as

for (var j=0, len2=cells.leng th; j<len2; j++)
Yes.
--
Rob

Feb 4 '07 #4

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

Similar topics

1
7267
by: BKM | last post by:
I'm using a VB6 WebBrowser control to get info from various web pages and, occasionally, my program stops when it finds a script error on the page. It won't resume until I click 'Yes' or 'No' on the script error message box. However, if I open an IE6 browser outside the program and manually go to the same page I don't get the Script Error...
1
1524
by: Jatinder Singh | last post by:
I am running a CGI Programme. which is throwing Premature script error for some inputs. I have checked and couldn't fig out the problem. Even error log is empty. Can anybody help me out of this or can I use try except to catch the Error and how? plz get back soon .Its urgent -- Regards,
1
5713
by: HolaGoogle | last post by:
Hi all, Can you please help me out with this???? i've been using body onload() for ages but since i changed my internet explorer (to 6.02) and OS (XP), i started to get this IE script error and i don't know how to get rid of it!!!! I read somewhere that if I put the onload event in an inline script tag at the bottom of the my form body, it...
5
2731
by: Tam Inglis | last post by:
I have a web browser contol working sweetly. However when it hits a page with java script that has an error it throws up a dialog box each time prompting me "Do you wish to continue running scripts on this page" How can i supress this message... its gotta be something simple and ive been hunting for the answer for ages... any help...
0
3574
by: John Constant | last post by:
Using the MS C++ Example http://support.microsoft.com/default.aspx?scid=kb;en-us;261003 I've successfully managed to trap and log Script Errors that are generated by the WebBrowser (IE 6) which is hosted by a C# application, see below. However I've completely failed to force the browser to continue processing script which *should* be...
0
1035
by: William D. Sossamon | last post by:
http://support.microsoft.com/default.aspx?kbid=818803 1.. You add the following form to a user control: <form id="Form1" name="Form1" runat="server">2.. You add the user control, for example, Workspace1, to a page. When you do this, an auto-generated script that is similar to the following script is added to the page: <form...
3
2610
by: Guy Debord | last post by:
Hello all, I know that this is a long shot, but I have a problem which someone reading this group *may* just be able to shed some light on. We have a new internal personnel planner/attendance system in place. It uses a web interface to allow members of staff to select their site location for any week, request leave and record absences. ...
1
1171
by: key3210 | last post by:
Hi there. Totally new to all this. First Timer. Well here is the problem. I recently started having script error messages popping up on my computer as soon as i log on, and it does not matter if I click yes or no, it will not go away! So I have to "x" out of it numerous times in order for it to finally vanish. However, another of the same bundle...
8
1309
by: jayavidya | last post by:
Whenever I run the PHP script on the browser, a script error : "Object not found" is generated. The script I'm working on is syntactically correct. How can I detect this error in the code?
6
3215
by: swethak | last post by:
Hi, I displayed the image taken from database.How to raotate that image using javascript.plz tell that how to start the logic.plz tell that some reference websites.
0
8184
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8328
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6581
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5375
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3820
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3845
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2334
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1434
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1158
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.