The following example are going to create an object to store the client
Information,
I would like to new the object to init all the properties by function:
setProperty()
Can I set the value to the object without using the global variable ?
Thank you.
///---------------The object -------------------------------
function clientENV {
var detect = navigator.userA gent.toLowerCas e();
this.os;
this.browser;
this.version;
setProperty();
}
///-------------Function------------------------------------
var theString, place, OS, browser, version;
function setProperty() {
if (checkIt('msie' )) browser = "Internet Explorer"
else if (checkIt('Firef ox')) browser = "Safari"
else if (checkIt('safar i')) browser = "Safari"
else if (checkIt('omniw eb')) browser = "OmniWeb"
else if (checkIt('opera ')) browser = "Opera"
else if (checkIt('webtv ')) browser = "WebTV";
else if (checkIt('icab' )) browser = "iCab"
else if (checkIt('konqu eror')) {
browser = "Konqueror" ;
OS = "Linux";
} else if (!checkIt('comp atible')) {
browser = "Netscape Navigator"
version = detect.charAt(8 );
}
else browser = "An unknown browser";
if (!version) version = detect.charAt(p lace + thestring.lengt h);
if (!OS) {
if (checkIt('linux ')) OS = "Linux";
else if (checkIt('x11') ) OS = "Unix";
else if (checkIt('mac') ) OS = "Mac"
else if (checkIt('win') ) OS = "Windows"
else OS = "an unknown operating system";
}
}
function checkIt(string) {
place = detect.indexOf( string) + 1;
thestring = string;
return place;
}