JSFAQIII-2:
----------------------------------------------------------- 6. Как определить - какой у юзера браузер? >> From : Artem Babadzhanyants // Browser propeties check library. Version 1.02 // (C) Zalog 2000. Permission granted to reuse and distribute. // e-mail: zalog@pyramid-studio.com function Browser(){
this.getCookieVal=Browser_getCookieVal; this.fixCookieDate=Browser_fixCookieDate; this.getCookie=Browser_getCookie; this.setCookie=Browser_setCookie; this.deleteCookie=Browser_deleteCookie; this.getHostName=Browser_getHostName; this.getHostAddress=Browser_getHostAddress; this.agent=navigator.userAgent.toLowerCase(); (navigator.appName)?this.name=navigator.appName:
this.securityPolicy=null; this.version=parseFloat(navigator.appVersion); if(navigator.cpuClass){
this.cpuClass="Unknown CPU class, including Sun SPARC"; if(navigator.cpuClass.indexOf("x86")!= -1)
this.cpuClass=null; (navigator.onLine) ? this.onLine=navigator.onLine :
expdate.setTime(expdate.getTime()+(365*24*60*60*1000)); this.fixCookieDate(expdate); this.setCookie("test_js","safe to delete",expdate,"/"); (this.getCookie("test_js")) ? this.cookieEnabled=true :
if(navigator.language)this.language=navigator.language; else if(navigator.browserLanguage)
(navigator.systemLanguage) ? this.systemLanguage = navigator.systemLanguage :
(this.agent.indexOf('compatible')==-1)&& (this.agent.indexOf('opera')==-1)&& (this.agent.indexOf('webtv')==-1)); this.Netscape2=(this.Netscape&&(this.versionHi==2)); this.Netscape3=(this.Netscape&&(this.versionHi==3)); this.Netscape4=(this.Netscape&&(this.versionHi==4)); this.Netscape4up=(this.Netscape&&(this.versionHi>=4)); this.Netscape5=(this.Netscape&&(this.versionHi==5)); this.Netscape5up=(this.Netscape&&(this.versionHi>=5)); this.NavigatorOnly=(this.Netscape&&((this.agent.indexOf(";nav")!=-1)||
this.IE=(this.agent.indexOf("msie") != -1); this.IE3=(this.IE&&(this.versionHi<4)); this.IE4=(this.IE&&(this.versionHi==4)&&
this.IE5=(this.IE&&(this.versionHi==4)&&
if(this.IE5){
this.version=parseFloat(this.agent.substr(this.agent.indexOf("5."))); this.AOL=(this.agent.indexOf("aol")!= -1); this.AOL3=(this.AOL&&this.IE3); this.AOL4=(this.AOL&&this.IE4); this.Opera=(this.agent.indexOf("opera")!=-1); this.WebTV=(this.agent.indexOf("webtv")!=-1); if(this.Netscape2||this.IE3)this.jsVersion=1.0; else if(this.Netscape3||this.Opera)this.jsVersion=1.1; else if((this.Netscape4&&(this.version<=4.05))||
else if(this.Netscape&&(this.versionHi>5))this.jsVersion=1.4; else if(this.IE&&(this.versionHi>5))this.jsVersion=1.3; else if(_jsVersion>1.3)this.jsVersion=_jsVersion; else this.jsVersion=0.0; this.vbVersion=vbVer; this.osWin=((this.agent.indexOf("win")!=-1)||
(this.agent.indexOf("win ce")!=-1));
(this.agent.indexOf("windows3.1")!=-1)|| (this.agent.indexOf("windows 16-bit")!=-1));
(this.agent.indexOf("windows16-bit")!=-1));
this.osWin32=(this.osWin95||this.osWinNT||this.osWin98||this.osWin2000||
(this.agent.indexOf("win32")!=-1)|| (this.agent.indexOf("32bit")!=-1)); this.osOS2=((this.agent.indexOf("os/2")!=-1)||
(this.agent.indexOf("ibm-webexplorer")!=-1)); this.osMac=(this.agent.indexOf("mac")!=-1); this.osMac68k=(this.osMac&&((this.agent.indexOf("68k")!=-1)||
this.osSun=(this.agent.indexOf("sunos")!=-1); this.osSun4=(this.agent.indexOf("sunos 4")!=-1); this.osSun5=(this.agent.indexOf("sunos 5")!=-1); this.osSuni86=(this.osSun&&(this.agent.indexOf("i86")!=-1)); this.osIrix=(this.agent.indexOf("irix")!=-1); this.osIrix5=(this.agent.indexOf("irix 5")!=-1); this.osIrix6=((this.agent.indexOf("irix6")!=-1)||
this.osHPUx9=(this.osHPUx&&(this.agent.indexOf("09.")!=-1)); this.osHPUx10=(this.osHPUx&&(this.agent.indexOf("10.")!=-1)); this.osAIX=(this.agent.indexOf("aix")!=-1); this.osAIX1=(this.agent.indexOf("aix 1")!=-1); this.osAIX2=(this.agent.indexOf("aix 2")!=-1); this.osAIX3=(this.agent.indexOf("aix 3")!=-1); this.osAIX4=(this.agent.indexOf("aix 4")!=-1); this.osLinux=(this.agent.indexOf("inux")!=-1); this.osSCO=(this.agent.indexOf("sco")!=-1)||
this.osMPRAS=(this.agent.indexOf("ncr")!=-1); this.osReliant=(this.agent.indexOf("reliantunix")!=-1); this.osDEC=((this.agent.indexOf("dec")!=-1)||
(this.agent.indexOf("dec_alpha")!=-1)|| (this.agent.indexOf("alphaserver")!=-1)|| (this.agent.indexOf("ultrix")!=-1)|| (this.agent.indexOf("alphastation")!=-1)); this.osBSD=(this.agent.indexOf("bsd")!=-1); this.osFreeBSD=(this.agent.indexOf("freebsd")!=-1); this.osOpenBSD=(this.agent.indexOf("openbsd")!=-1); this.osNetBSD=(this.agent.indexOf("netbsd")!=-1); this.osBSDi=(this.agent.indexOf("bsdi")!=-1); this.osUnix=((this.agent.indexOf("x11")!=-1)||
this.osSCO||this.osUnixWare||this.osMPRAS|| this.osReliant||this.osDEC||this.osSinix|| this.osAIX||this.osLinux||this.osBSD|| this.osFreeBSD);
this.hostAddress=null; this.hostName=this.getHostName(); this.hostAddress=this.getHostAddress(); this.checkScreen(); function Browser_checkScreen(){
(screen.colorDepth) ? this.colorDepth = screen.colorDepth : this.colorDepth = null; if(screen.width&&screen.height){
this.screenHeight=screen.height; this.screenResolution=this.screenWidth+"x"+this.screenHeight;
this.screenHeight=null; this.screenResolution=null; if(screen.availWidth&&screen.availHeight){
this.availHeight=screen.availHeight; this.availResolution=this.availWidth+"x"+this.availHeight;
this.availHeight=null; this.availResolution=null; if(this.screenWidth && this.screenHeight&&this.colorDepth)
this.colorDepth=null; this.availWidth=null; this.availHeight=null; this.availResolution=null; this.screenWidth=null; this.screenHeight=null; this.screenResolution=null; this.Resolution=null; if(window.innerWidth) this.innerWidth = window.innerWidth; else{
if(window.innerHeight) this.innerHeight = window.innerHeight; else{
(this.innerWidth&&this.innerHeight) ?
this.innerResolution = null;
this.outerWidth = null;
this.outerHeight = null;
this.outerResolution = null;
this.offscreenBuffering = null; else this.frameRate = null; function Browser_getCookieVal(offset){
if(endstr==-1)endstr=document.cookie.length; return unescape(document.cookie.substring(offset,endstr)); function Browser_fixCookieDate(date){
var skew=base.getTime(); if(skew>0)date.setTime(date.getTime()-skew); function Browser_getCookie(name){
var alen=arg.length; var clen=document.cookie.length; var i=0; while(i<clen){
if(document.cookie.substring(i,j)==arg)return this.getCookieVal(j); i=document.cookie.indexOf(" ",i)+1; if(i==0)break; return null; function Browser_setCookie(name,value,expires,path,domain,secure){
expires="+expires.toGMTString():"")+((path)?"; path="+path:"")+((domain)?"; domain="+domain:"")+((secure)?"; secure":""); function Browser_deleteCookie(name,path,domain){
path="+path:"")+((domain)?"; domain="+domain:"")+"; expires=Thu, 01-Jan-70 00:00:01 GMT"; function Browser_getHostName(){
hostAddress=java.net.InetAddress.getLocalHost(); return(hostAddress.getHostName()); |