Welcome to WebmasterWorld Guest from 54.167.213.22

Forum Moderators: incrediBILL

Message Too Old, No Replies

browser document internal differences

why some things work in MOZ but not IE and visa versa

     
5:33 pm on Aug 26, 2005 (gmt 0)

10+ Year Member




hi everyone... it's been a long while since i've been by here... i've a slight problem with a page i'm working on and not sure exactly where to post...

the problem stems from IE and MOZ having different namings for the document internals... for example,in a javascript,

var former = document.forms.quiz;

accesses the elements of a form named "quiz" like "former.q5[0].checked"... this works in IE but fails in MOZ...

basically, i'm down to needing some basic browser detection and then being able to assign the vars based on the browser and hopefully everything will fall neatly into place... the problem is that i don't know what the different browsers use for their internal document structure namings... that and i can't locate my browser detection stuffs :(

5:41 am on Aug 27, 2005 (gmt 0)

10+ Year Member




i solved this after locating and consulting the DOM specs for GECKO which MOZ and other browsers are built on.

the solution was to code the following...

function analyzeForm() {
var total = 0;
// document.all exists in IE
if (document.all) {
former = document.forms.quiz;
}
// document.getElementById() is used with GECKO browsers
else if (document.getElementById("quiz")) {
former = document.getElementById("quiz");
}
[do whatever]
}

one place that i thought i'd have problems was updating the textarea with the result message. however, "document.quiz.result.value = msg;" where msg has been assigned a value works just fine in both IE and MOZ which i find rather "interesting"... especially since the textarea resides within the form container...

 

Featured Threads

Hot Threads This Week

Hot Threads This Month