判断几种浏览器类型的表达式

  1. // IE浏览器
  2. if (/MSIE/.test(navigator.userAgent)){     
  3.   
  4. // Chrome浏览器
  5. else if (/Chrome/.test(navigator.userAgent)){     

  6. // Firefox浏览器
  7. else i( /Firefox/.test(navigator.userAgent)){

  8. 也有这么写的:
  9.   // 这段函数的意思是判断浏览器为Firefox浏览器,其他浏览器也可以按不照搬  
  10. navigator.userAgent.indexOf('Firefox') >= 0
     

猜你喜欢

转载自lgscofield.iteye.com/blog/1740180