Click to See Complete Forum and Search --> : Browser compatibility issue document.getElementById vs. document.all


jibip
02-26-2003, 05:08 PM
I've got quite an interesting problem, which I haven't come across before. I made an interactive form, so that if you select a category from the select list, the form below changes. In MSIE using document.all, this works fine, in netscape using document.getElementById this doesn't. It'll change once and never again. I'll provide you with a selection of the code I created, there is much more.
this is a major problem if i can't get this to work on both NS and IE, so i'm willing to take any suggestions.

Thanks,

Andy

gil davis
02-26-2003, 05:41 PM
You neglected to mention what version of Netscape.

I use this snippet to create the function if getElementById() does not exist:<script>
// this routine adds the function getElementById to an old browser
if (!document.getElementById) {
document.getElementById = function(strID) {
if (document.layers) return document[strID];
if (document.all) return document.all[strID];
return null; // expect the unexpected
}
}
</script>
You still have to handle the DOM differences (NS 4 does not support object.style, but you just have to detect document.layers to use NS 4's DOM.

jibip
02-27-2003, 02:47 PM
thanks but still unsuccessful. I tried putting your code in before the document.getElementById declaration in the if statement, but still come up with the same problem in netscape. I am using v6.2. Does anyone know if this is just some sort of stack overflow problem with the browser?

if i pop an alert box up with a that displays the values, which are either 0, 1, or 2. it'll work for the first 2 times i select something in the box, after that it gives tells me undefined.

Any thoughts?

celebguy_dv
03-04-2003, 03:33 AM
http://banners.dollarmachine.com/pic/2014000/hal001.gif (http://www.kinkyceleb.com/1261795520)