Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getElementByID not working on Netscape

Status
Not open for further replies.

KlaudiaS

Programmer
Sep 15, 2006
3
RO
Hello there!

I made a function to hide/show menus and submenus and the funtion is working on IE6.0, but not in Netscape 4.78(where I need to use the function).Look my function:

function toggle(id)
{
var objTable = document.getElementById('tbl_menu');
// var objTable = document.getElementByName('tbl_menu');
var objRows = objTable.rows;
var row;
for(i=0;i<objRows.length;i++)
{
row = objRows;
if(row.name==id)
row.style.display=(row.style.display=='none')?'':'none';
}


}

The 'tbl_name' it is the name of the table where I am keeping the menus/submenus.The problem is that for Netscape 4.78 I can't get the name of the table.I tried to use getElementByName, but it is not working too.Can anybody help?
 
There is not getElementByName, it is getElementsByName which returns an array of elements.

I have no experience with Netscape and getElementById but wanted to warn you on the ByName so you did not waste any time on it.

Good luck.

At my age I still learn something new every day, but I forget two others.
 
Netscape 4.x doesn't support document.getElement by anything. The things you want to do are going to be REAL difficult in Netscape with anything before version 6.0.

Lee
 
Netscape 4.78?!!!!!?????? Goodness me!

I assume you are attempting to retrofit a site for someone still stuck in the last century? Would be worthwhile suggesting to them that they look into alternative browsers? I don't think even the investment banks are running NS4.x now (and they were the last I knew of).

Anyways... Netscape didn't support document.getElementById() until the next major release (version 6.x which came out in April 2000). Instead it used a different model... they used document.layers.

So... assuming the following HTML:
Code:
<p id="intro">This is some text</p>

You could access it like this in javascript to set the background colour:
Code:
document.layers['intro'].bgColor = "#CC0000";

Hope that gets you started!

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
Hi again!

For my problem with name of the table I tried what Jeff told me and stil not working!Can anybody help me with another sugestion?
Thanks a lot!
 
The best thing would be to have your clients upgrade to a newer version of Netscape or one of the other current browsers. Other than that, find an older book on Javascript that was written while Netscape 4.x was current, and look through that to see what you can use.

Lee
 
Thank you for your answer Lee,

Unfortunety I can't convince my client to upgrade to a new version of Netscape.I will try to find a book,but the problem is that I need to find a solution quickly.Still you don't know a site where I can find what I need?

Thank you anyway.
 
It's been several years since I did any work to be compliant to Netscape 4.x. Try redesigning the site to not have the fancy stuff. You can always tell your client that Netscape 4.x doesn't allow the kind of thing they want. According to an older Javascript Bible I have, the style object wasn't available in Netscape until version 6. If your code will be used ONLY in the environment where Netscape 4.x is used, you won't have to write a version for modern browsers (the older Netscape browsers have a LOT of proprietary things that won't work in any other type of browser).

If you really insist on doing this, then do a search on Netscape layers. I think you'll find a concensus here that writing Javascript for Netscape 4.x is a lot like designing new parts for a Model T Ford.

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top