$(function(){ var browser = (function(){ var ua = window.navigator.useragent.tolowercase(), sys = null, s; if(s = ua.match(/rv:([\d.]+)\) like gecko/)){sys = {type:'ie',version:s[1]};} else if(s = ua.match(/msie ([\d.]+)/)){sys = {type:'ie',version:s[1]};} else if(s = ua.match(/firefox\/([\d.]+)/)){sys = {type:'firefox',version:s[1]};} else if(s = ua.match(/chrome\/([\d.]+)/)){sys = {type:'chrome',version:s[1]};} else if(s = ua.match(/opera.([\d.]+)/)){sys = {type:'opera',version:s[1]};} else if(s = ua.match(/version\/([\d.]+).*safari/)){sys = {type:'safari',version:s[1]};} else if(s = ua.match(/ucbrowser\/([\d.]+)/)){sys = {type:'uc',version:s[1]};} else if(s = ua.match(/micromessenger\/([\d.]+)/)){sys = {type:'wx',version:s[1]};} else{sys = {type:'unknown',version:'unknown'};} sys.ismobile = !!ua.match(/applewebkit.*mobile.*!/) || !!ua.match(/(iphone|ipod|android|ios|ipad)/i); return sys; })(); /*检测ie*/ if(browser.type =="ie" && browser.version < 8){ location.href="http://www.jltech.cn/upgradebrowser/"; } /*判断谷歌27*/ if(browser.type == 'chrome' && browser.version <= 27){ $('.font_scale8, .font_scale10').addclass('font_adjust'); } /*======返回顶部======*/ window.onload = function(){ imgcenter(".index .section3 .list .img "); imgcenter(".business_list2 ul li.lis .img"); } }) function imgcenter(s) { $(s).each(function() { var t = $(this), i = $(this).children("img"), r1 = t.width() / t.height(), r2 = i.width() / i.height(); if(r1 > r2) { $(this).children("img").css({ 'margin-top': (t.height() - (t.width() / r2)) / 2, 'width': '100%', 'height': t.width() / r2 }); } else { $(this).children("img").css({ 'margin-left': (t.width() - (t.height() * r2)) / 2, 'width': t.height() * r2, 'height': '100%' }); } }) }