// 判断浏览器类型 var browserName = navigator.userAgent.toLowerCase(); var mybrowser = { version : (browserName.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [0, '0'])[1], safari : /webkit/i.test(browserName) && !this.chrome, opera : /opera/i.test(browserName), firefox : /firefox/i.test(browserName), msie : /msie/i.test(browserName) && !/opera/.test(browserName), mozilla : /mozilla/i.test(browserName) && !/(compatible|webkit)/.test(browserName) && !this.chrome, chrome : /chrome/i.test(browserName) && /webkit/i.test(browserName) && /mozilla/i.test(browserName) }
// 使用范例
$(this).css("top", mybrowser.msie ? "-2px" : "-3px").children("img") .eq(0).css({ "cursor" : "pointer", "position" : "relative", "top" : mybrowser.msie ? "-2px" : "-3px" });