I'm testing something on an old version of netscape, specifically 4.7. Everythings fine except for my javscript function doesn't work because it says getElementById is not a function:

document.getElementById('ncp').src = "ncp" + pictureNum + ".jpg";


I've got many more of these type lines but it works fine in IE and FF. Is there something I can do to make this compatible with netscape browsers?

Recommended Answers

All 5 Replies

You'll have to navigate the hierarchy. For example, use the document.images collection.

I made the decision long ago that I simply wasn't going to worry myself, or add huge development overhead, to supporting old browers, particularly for corporate development projects and/or sites. Use a strict DOCTYPE, code to that standard, cut down on the fancy stuff, and use server-side code as much as possible.

I just decided to scrap the idea. I couldn't get anything to work without changing a bunch of code. I think to really get it to work you have to use layers with netscape, but it's just not worth it.

Thanks for the help!

Netscape 6+ supports getElementById.
If you require support for Netscape 4 (about 1 visitor in 500 or less now) then you need to use document.layers instead just for those visitors and use getElementById for everyone else.

Yeah, the layers is the only way in netscape.

document.getElementById("supplier_no").value = values_array[0];

java script: some times i get error as getElementById is invalid function or returns null. It works perfect in IE but not in Firefox. what is the reason...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.