473,325 Members | 2,308 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,325 software developers and data experts.

works in IE but not in firefox

hi

i have a table (leftmenu), the cells of this table has a <A> link in them.

<table class="menu_table" width="100%" cellspacing="0" cellpadding="0"
id="leftmenu">
<tr>
<td><a class="menu_link" href="/hb/home/">Home</a></td>
</tr>
</table>
i am having problems with this script
alert(leftmenu.cells(0).innerText)

in IE this gives the text of the link - Home

but in firefox - i dont even get the alert.

i have tried

document.leftmenu...

and

window.leftmenu...

with no success.

all help appreciated.

Kal
Jul 23 '05 #1
3 1897
diablo wrote:
hi

i have a table (leftmenu), the cells of this table has a <A> link in them.

<table class="menu_table" width="100%" cellspacing="0" cellpadding="0"
id="leftmenu">
<tr>
<td><a class="menu_link" href="/hb/home/">Home</a></td>
</tr>
</table>
i am having problems with this script
alert(leftmenu.cells(0).innerText)

in IE this gives the text of the link - Home

but in firefox - i dont even get the alert.


That's because you used many IE specific functions.

This will work in both browsers:
alert(document.getElementById('leftmenu').rows[0].cells[0].firstChild.firstChild.nodeValue);

You might make it easier by extending the link with a unique id and do:
alert(document.getElementById('leftmenulink').firs tChild.nodeValue);
Jul 23 '05 #2

Well, alert(leftmenu.cells(0).innerText) is completely improper call to
an IDed object, leftmenu.cells[0] is addressing the GLOBAL object
'leftmenu', use document.getElementById(YOURIDHERE), which is the proper
way, and as for innerText, mozilla uses .textContent, same object really,
so:
_text=(/(microsoft|opera)/i.test(navigator.appName)) ? 'innerText' :
'textContent';
document.getElementById('leftmenu').cells[0][_text];
// opera uses .innerText as well

or as the other fella said, use DOM nodeValue on the childNode.

Danny

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Jul 23 '05 #3
On 13/07/2005 00:38, Danny wrote:

[snip]
_text=(/(microsoft|opera)/i.test(navigator.appName)) ? 'innerText'
: 'textContent';
document.getElementById('leftmenu').cells[0][_text];
// opera uses .innerText as well
If you want to talk about 'proper' then don't recommend browser
detection. Test if innerText or textContent is a string property of the
object.
or as the other fella said, use DOM nodeValue on the childNode.


I'd prefer that as it's likely to have better support over a wider range
of browsers.

Mike

--
Michael Winter
Prefix subject with [News] before replying by e-mail.
Jul 23 '05 #4

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

Similar topics

14
by: tshad | last post by:
I posted this on the asp.net group, also. I wasn't sure whether this was an asp.net problem or a javascript problem. I have a page that was originally created from a program I found on the net...
5
by: Derek Erb | last post by:
I am banging my head against the wall with this one. The following code snippets work perfectly fine in MSIE6. But produce an error in Firefox and do not work at all. BROWSER.HTM <HTML> .......
11
by: lkrubner | last post by:
We are working on a website that is here: http://www.lauradenyes.com/ The site was working till I put up an .htaccess file that was suppose to redirect all html files to the PHP parser. The...
14
by: David Blickstein | last post by:
I have some XML documents that I want to open in a web browser and be automatically translated to HTML via XSLT. I'm using an xml-stylesheet processing command in a file called "girml.xml". ...
3
by: KBuser | last post by:
I recently developed an internal website with various queries against our SQL server. I added buttons with Response.Redirect. These buttons do not work with Internet Explorer, however when using...
4
by: puja | last post by:
hi all, I have an asp.net website where am including .css file dynamically on page load event. For diff users, there is diff CSS file. So after user logs in, I am setting CSS href on page load....
28
by: entfred | last post by:
I have the following line of html: &nbsp;&nbsp1234&nbsp;&nbsp;&nbsp;&nbsp;&nbspabc&nbsp;&nbsp;&nbspyow In Internet Explorer 6.0, the columns look ok using the above html: 1234 abcd ...
3
by: Arodicus | last post by:
I have a static class method, MyObject.MySub.MyMethod(), which points to a handler in a Flash SWF (but I think that's inconsequential). In reality, the path is a lot longer, so I'd like to make a...
13
by: Stever1975 | last post by:
I'm working on something similiar to a shopping cart item page. There is a table of items. Each item has an image, a textbox for the qty and an image for the add button. When the add image is...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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...
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.