works in IE but not in firefox

D

diablo

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
 
R

Robert

diablo said:
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').firstChild.nodeValue);
 
M

Michael Winter

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,444
Messages
2,571,709
Members
48,796
Latest member
Greg L.
Top