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

时间:2009-04-10    点击:144   
// 判断浏览器类型
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");
}
由document.body和document.documentElement想到的
js cookies 常见网页木马挂马代码 24小时只加载一次
javascript removeChild 使用注意事项
Firefox window.close()的使用注意事项
javascript html 静态页面传参数
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved