homepage Welcome to WebmasterWorld Guest from 54.205.189.156
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

    
browser document internal differences
why some things work in MOZ but not IE and visa versa
wkitty42




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


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 :(

 

wkitty42




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


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...

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved