Home > Web Front-end > JS Tutorial > js 判断浏览器类型 去全角、半角空格 自动关闭当前窗口_javascript技巧

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

WBOY
Release: 2016-05-16 18:54:13
Original
995 people have browsed it

// 判断浏览器类型
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");
}

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template