473,320 Members | 1,957 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,320 software developers and data experts.

This works in IE but not in Mozilla

I have some functions in a script in which I'm manipulating the
innerText and background colors of certain rows in a table. The lines
below work OK in IE but when I try them in Mozilla, I get an error
that says: "document.getElementById('TableX').rows is not a
function".

thisRow = document.getElementById('TableX').rows(1);
thisRow.style.background = 'white';

Can anyone give me a clue as to how to fix this so that it will work
in both browsers?

Thanks.
Jul 23 '05 #1
2 2525
DU
Martin wrote:
I have some functions in a script in which I'm manipulating the
innerText

Mozilla and Firefox do not support innerText. Use DOM 3 textContent()
instead for Mozilla and Firefox.

and background colors of certain rows in a table. The lines below work OK in IE but when I try them in Mozilla, I get an error
that says: "document.getElementById('TableX').rows is not a
function".

thisRow = document.getElementById('TableX').rows(1);
() identifies parameters of a function while [] identifies the accessor
of an array.
So
thisRow = document.getElementById('TableX').rows[1];
will work in both browsers.
thisRow.style.background = 'white';
thisRow.style.backgroundColor = 'white';

Can anyone give me a clue as to how to fix this so that it will work
in both browsers?

Thanks.


DU
--
The site said to use Internet Explorer 5 or better... so I switched to
Mozilla 1.7.6 :)
Jul 23 '05 #2
Martin wrote:
I have some functions in a script in which I'm manipulating the
innerText and background colors of certain rows in a table. The lines
below work OK in IE but when I try them in Mozilla, I get an error
that says: "document.getElementById('TableX').rows is not a
function".

thisRow = document.getElementById('TableX').rows(1);
thisRow.style.background = 'white';

The rows collection is like a reduced functionality array, you must
address its members the same as elements in an array:

thisRow = document.getElementById('TableX').rows[1];

And the correct way to modify an element's background color using its
style object is:

this.style.backgroundColor = 'white';

You should also do feature detection before using either
getElementById or style:

if (document.getElementById) {
thisRow = document.getElementById('TableX').rows[1];
}
if (thisRow.style) {
thisRow.style.backgroundColor = 'white';
}

Of course you only need to test for these once, and it may be helpful
to provide alternative methods for browsers that don't support them.

Have a look at the group FAQ for help on this and the square/round
bracket issue.

<URL:http://www.jibbering.com/faq/>
Can anyone give me a clue as to how to fix this so that it will work
in both browsers?


As was noted in DU's post, innerText will not work in
Firefox/Mozilla (or most browsers other than IE).

There are some suggestions in the thread below on cross-browser
implementations of innerText functionality (please excuse wrapping)
or search for 'innerText' in this newsgroup on 27 March 2005:
<URL:http://groups-beta.google.com/group/comp.lang.javascript/browse_thread/thread/77f653baa1044486/ed976a3594350a25?q=innerText&rnum=2#ed976a3594350a 25>

--
Rob
Jul 23 '05 #3

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

Similar topics

6
by: somebody | last post by:
I'm trying to change a users password on a Linux system by spawning a process. Here's what the command looks like on the command line: echo 'myuser:mypasswd' | chpasswd It uses a pipe, which...
4
by: Marek Mänd | last post by:
xHTML 1.0 strict and valid css. But though only IE shows up like I like it. Not Opera7.50PR1, not Mozilla1.6. Mozilla and Opera doesnt take interest in absolute positioning herein this...
4
by: Andrew Poulos | last post by:
I'm using the following code to dynamically build an OBJECT tag to display a QuickTime movie: window.onload = function() { addParam = function(p,n,v) { /* parent, name, value */ var c =...
3
by: Greg | last post by:
Javascript Folks, I am relatively new to javascript and am working on a script where I want to utilizes a couple of iframes and format text in them. I have run into a problem with getting the...
1
by: Feudalac! | last post by:
Working file at: http://www.elma.hr/test.php code of menu system at: http://www.elma.hr/test_code.htm in mozilla drop down menus are not shown... but in IE everything works fine...
6
by: Ook | last post by:
I've given up on MySQL for now - and just built a basic c# dotnet asp web app. It works. However, if I try to view the app in a non-Microsoft browser, it doesn't do anything. Specifically, I'm...
7
by: Dayo | last post by:
Hello folks. Sorry if this seems a bit silly, I have no experience with this type of code. Here is a fading script for an Image Gallery I am looking to fix. It works with IE and Safari but not...
1
by: sarath chandran | last post by:
Hi Iam trying to make my application work in Mozilla. The below piece of code works well in IE but throws error in Mozilla. Can you modify the below piece of code so that it supports IE and...
0
by: needhipandya | last post by:
Hi i am using a function to check-uncheck all checkboxes... That works fine in mozilla but doesnt works in IE. Gives "event is null or not an object" error in status bar (in IE)... I have used same...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.