一个不错的可以检测多中浏览器的函数和其它功能第1/2页
2024-09-06 12:42:50
供稿:网友
//Examine the browser 检测浏览器的函数
var userAgent = navigator.userAgent.toLowerCase();
var is_opera = (userAgent.indexOf('opera') != -1);
var is_saf = ((userAgent.indexOf('applewebkit') != -1) || (navigator.vendor == 'Apple Computer, Inc.'));
var is_webtv = (userAgent.indexOf('webtv') != -1);
var is_ie = ((userAgent.indexOf('msie') != -1) && (!is_opera) && (!is_saf) && (!is_webtv));
var is_ie4 = ((is_ie) && (userAgent.indexOf('msie 4.') != -1));
var is_moz = ((navigator.product == 'Gecko') && (!is_saf));
var is_kon = (userAgent.indexOf('konqueror') != -1);
var is_ns = ((userAgent.indexOf('compatible') == -1) && (userAgent.indexOf('mozilla') != -1) && (!is_opera) && (!is_webtv) && (!is_saf));
var is_ns4 = ((is_ns) && (parseInt(navigator.appVersion) == 4));
var is_mac = (userAgent.indexOf('mac') != -1);
//Global registers
var currentblogid;
var currentstarid;
var currentcommentid;
var switchcomandmes;
var securitycodejs=null;
var onetimecounter=1;
//Get absolute path, fix bug of IE when base path is set
var gotourl = location.href;
var absbaseurl;
var abspath;
var r_identifier=gotourl.lastIndexOf("/read.php/");
var r_identifier2=gotourl.lastIndexOf("/post/");
var r_identifier3=gotourl.lastIndexOf("/tag/");
if (r_identifier==-1) {
r_identifier=r_identifier2;
}
if (r_identifier==-1) {
r_identifier=r_identifier3;
}
if (r_identifier!=-1) {
absbaseurl = gotourl.substr(0, r_identifier)+"/";
var simplegotourl=absbaseurl.replace("http://", '');
r_identifier2=simplegotourl.indexOf("/");
abspath=simplegotourl.substr(r_identifier2+1);
} else {
absbaseurl='';
abspath=null;
}
//Is Ajax supported?
if ((is_ie & !is_ie4) || is_moz || is_saf || is_opera) var shutajax=0;
else var shutajax=1;
//For firefox, tell Firefox not to display the content you input in last session