js 验证

/****************** 计算对象的位置 *************************/
function getAbsolutePos(el) {
var r = { x: el.offsetLeft, y: el.offsetTop };
if (el.offsetParent) {
var tmp = getAbsolutePos(el.offsetParent);
r.x += tmp.x;
r.y += tmp.y;
}
return r;
}

//各种浏览器的判断参数
var isIE6 = false;
var isIE = false;
var firefox = false;
var chrome = false;
var opera = false;
var safari = false;
var Sys = {};
var ua = navigator.userAgent.toLowerCase();
var s;
(s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] :
(s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] :
(s = ua.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] :
(s = ua.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] :
(s = ua.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0;

//以下进行参数的赋值
if (Sys.ie) {
isIE = true;
if(Sys.ie == 6){
isIE6 = true;
}
}
if (Sys.firefox) firefox = true;
if (Sys.chrome) chrome = true;
if (Sys.opera) opera = true;
if (Sys.safari) safari = true;

//各种获取对象的函数
//通过id找对象
function getId(id){
if(document.getElementById(id))
return document.getElementById(id);
else
return false;
}
//通过id中的关键字找一类对象
function getObjID(type,keyword,fid){
var fobj = typeof(fid) == "undefined"?document:getId(fid);
var newArr = new Array();
var items = fobj.getElementsByTagName(type);
for(var i=0;i<items.length;i++){
if(items[i].id && items[i].id.indexOf(keyword)>=0){
newArr.push(items[i]);
}
}
return newArr;
}

//鼠标经过显示列表详情
function showDetail(actObj,fid){
var fobj = getId(fid);
var num = actObj.id.split("_")[1];
var details = getObjID("li","itemDetail_",fid);
var simples = getObjID("li","itemSimple_",fid);

for(var i=0;i<details.length;i++){
details[i].style.display = "none";
simples[i].style.display = "block";
}
actObj.style.display = "none";
getId("itemDetail_"+num).style.display = "block";
}


/*************切换TAB页****************/
function changeTab(itemID,contentID,id, total)
{
var theTabTitle = document.getElementById(itemID+id);
var theTabContent = document.getElementById(contentID+id);
for(var i=1; i<=total; i++)
{
var tempTabTitle = document.getElementById(itemID+i);
var tempTabContent = document.getElementById(contentID+i);
tempTabTitle.className = "tab_title_normal";
tempTabContent.style.display = "none";
}
theTabTitle.className = "tab_title_on";
theTabContent.style.display = "";
}

你可能感兴趣的:(chrome,Opera,IE,firefox,Safari)