var NAV_UNKNOW = 0;
var NAV_OPERA = 1;
var NAV_IE = 2;
var NAV_NETSCAPE = 3;
var NAV_MAZILLA = 4;
var V_SHOW = 1;
var V_HIDE = 0;
var nNavigatorType;
var VER_NUMBER = 1.0;
function parseNavigatorType(){
try{
var sUserAgent = window.navigator.userAgent ;
if ( sUserAgent.indexOf("Opera")>0 ){
return NAV_OPERA;}
if ( sUserAgent.indexOf("MSIE")>0 ){
var n = sUserAgent.indexOf("MSIE")+5;
var sVer = sUserAgent.substring(n);
n = sVer.indexOf(";");
VER_NUMBER = sVer.substring(0, n);
return NAV_IE;}
if ( sUserAgent.indexOf("Netscape/")>0 ){
var n = sUserAgent.indexOf("Netscape/");
VER_NUMBER = window.navigator.vendorSub;
return NAV_NETSCAPE;}
if ( sUserAgent.indexOf("Mozilla")>=0 && sUserAgent.indexOf("Gecko")>0 ){
var n = sUserAgent.indexOf("rv:")+3;
var sVer = sUserAgent.substring(n);
n = sVer.indexOf(")");
VER_NUMBER = sVer.substring(0, n);
return NAV_MAZILLA;}} catch ( e ) {}
return NAV_UNKNOW;}
nNavigatorType = parseNavigatorType();
function getNavigatorType(){
return parseInt(nNavigatorType);}
function getNavigatorVersion(){
return VER_NUMBER;}
function getNavigatorString(){
var sBrowser = ["Unknow", "Oper", "IE", "Netscape", "Mozilla"];
return sBrowser[getNavigatorType()];}
function IsSupportedBrowser(){
switch ( nNavigatorType ){
case NAV_NETSCAPE:
if ( VER_NUMBER<7.0 )
return false;
break;
case NAV_IE:
if ( VER_NUMBER<5.5 )
return false;
break;
case NAV_MAZILLA:
if ( VER_NUMBER<"1.4" )
return false;
break;
case NAV_OPERA:
default:
return false;}
return true;}
function getBrowserLanguage(){
if ( getNavigatorType()==NAV_IE ){
return window.navigator.browserLanguage;}
return window.navigator.language;}
function getBrowserInfo(){
var sInfo = "";
sInfo += "
| Public information in IE and Netscape:"
sInfo += " |
| appCodeName: | " + window.navigator.appCodeName;
sInfo += " |
| appName: | " + window.navigator.appName;
sInfo += " |
| cookieEnabled: | " + window.navigator.cookieEnabled;
sInfo += " |
| mimeTypes: | " + window.navigator.mimeTypes;
sInfo += " |
| platform: | " + window.navigator.platform;
sInfo += " |
| plugins: | ";
for ( var i=0; i< window.navigator.plugins.length; i++){
sInfo += ""+window.navigator.plugins[i].name;};
sInfo += "| userAgent: | " + window.navigator.userAgent;
sInfo += " | | javaEnabled: | " + window.navigator.javaEnabled();
sInfo += " | | clientInformation: | " + window.clientInformation;
switch ( nNavigatorType ) {
case NAV_IE:
sInfo += " | | Information only in IE:"
sInfo += " | | browserLanguage: | " + window.navigator.browserLanguage;
sInfo += " | | appMinorVersion: | " + window.navigator.appMinorVersion;
sInfo += " | | cpuClass: | " + window.navigator.cpuClass;
sInfo += " | | onLine: | " + window.navigator.onLine;
sInfo += " | | systemLanguage: | " + window.navigator.systemLanguage;
sInfo += " | | userLanguage: | " + window.navigator.userLanguage;
sInfo += " | | userProfile: | " + window.navigator.userProfile;
break;
case NAV_NETSCAPE:
case NAV_MAZILLA:
sInfo += " | | Information only in Netscape:"
sInfo += " | | language: | " + window.navigator.language;
sInfo += " | | oscpu: | " + window.navigator.oscpu;
sInfo += " | | product: | " + window.navigator.product;
sInfo += " | | productSub: | " + window.navigator.productSub;
sInfo += " | | vendor: | " + window.navigator.vendor;
sInfo += " | | vendorSub: | " + window.navigator.vendorSub;
break;
case NAV_OPERA :
default:
return "unknow";}
return "";}
function getVisibility(ShowOrHide){
switch ( nNavigatorType ) {
case NAV_OPERA :
case NAV_IE:
case NAV_NETSCAPE:
case NAV_MAZILLA:
return ShowOrHide==V_SHOW ? "visible" : "hidden";
default:
return "unknow";}}
function MyEvent(evnt){
switch ( nNavigatorType ) {
case NAV_OPERA :
case NAV_IE:
if ( evnt==null )
evnt = event;
this.element = evnt.srcElement;
this.clientX = evnt.clientX;
this.clientY = evnt.clientY;
this.screenX = evnt.screenX;
this.screenY = evnt.screenY;
this.type = evnt.type;
return this;
case NAV_NETSCAPE0:
case NAV_NETSCAPE6:
case NAV_MAZILLA:
if ( evnt==null )
return null;
this.element = evnt.target;
this.clientX = evnt.pageX;
this.clientY = evnt.pageY;
this.screenX = evnt.screenX;
this.screenY = evnt.screenY;
this.type = evnt.type;
alert(this.element.innerHTML);
return this;
default:
elert("def");
return null;}}
function addEvent(obj, sEvent, sFunction){
if ( getNavigatorType()==NAV_IE ){
obj.setAttribute(sEvent,new Function(sFunction));}
else {
obj.setAttribute(sEvent,sFunction);}
return true;}
| |