js 判断浏览器类型 去全角、半角空格 自动关闭当前窗口

  // 判断浏览器类型

  function GetIEType()

  {

  var Sys = {};

  var nvg = navigator.userAgent.toLowerCase();

  var rslt;

  if (window.ActiveXObject)

  {

  Sys.ie = nvg.match(/msie ([\d.]+)/)[1];

  }

  (rslt = nvg.match(/firefox\/([\d.]+)/)) ? Sys.firefox = rslt[1] :

  (rslt = nvg.match(/chrome\/([\d.]+)/)) ? Sys.chrome = rslt[1] :

  (rslt = nvg.match(/version\/([\d.]+).*safari/)) ? Sys.safari = rslt[1] : 0;

  if (Sys.ie)

  {

  alert('IE: '+ Sys.ie);

  }

  if (Sys.firefox)

  {

  alert('Firefox: ' + Sys.firefox);

  }

  if (Sys.chrome)

  {

  alert('Chrome: ' + Sys.chrome);

  }

  if (Sys.safari)

  {

  alert('Safari: ' + Sys.safari);

  }

  }

  // 去文全角半角空格------------------------

  // 使用时将"丂"替换成全角空格

  String.prototype.trim = function()

  {

  return this.replace(/[丂*]|[ *]/g,"");

  }

  // 去左空格

  String.prototype.ltrim = function()

  {

  return this.replace(/^[丂*]|[ *]/g,"");

  }

  // 去右空格

  String.prototype.rtrim = function()

  {

  return this.replace(/[丂*]|[ *]*$/,"");

  }

  // 匹配Email格式

  function check_email(email)

  {

  if( email.match(/^[-+0-9a-z.=_\/]+@([-0-9a-z]+\.)+[a-z]{2,6}$/i) )

  return true;

  else

  {

  alert( "Error!");

  return false;

  }

  }

  // 自动关闭当前窗口

  window.onload = function()

  {

  window.setTimeout("next();",3000);

  };

  function next()

  {

  alert("OK");

  }