473,396 Members | 1,683 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.

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.getElementById('t1');
var cellsarr = new Array();
var chosenarr = new Array();
for(var i = 0; i<obj.cells.length;i++)
{
cellsarr[cellsarr.length]=obj.cells[i];
if(obj.cells[i].getAttribute('bgColor')=='#000000')
{
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 1994
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.getElementById('t1');
What is obj now?

var cellsarr = new Array();
var chosenarr = new Array();
for(var i = 0; i<obj.cells.length;i++)
The only W3C DOM object that has a cells property is one that implements
the HTMLTableRowElement 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.length; 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.net.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.getElementById('t1');

What is obj now?

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

The only W3C DOM object that has a cells property is one that implements
the HTMLTableRowElement 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.length; 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.length; 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@layswrote:
[...]
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.length; 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
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...
1
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...
1
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...
5
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...
0
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...
0
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,...
3
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...
1
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...
8
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
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
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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.