// 判断浏览器类型 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"); }
推荐阅读
javascript 兼容鼠标滚轮事件
这个事件在标准下和IE下是有区别的。firefox是按标准实现的,事件名为"DOMMouseScroll ",IE下采用的则是"mousewheel "。当然一行代码就解决了兼容问题 复制代码 代码如下:var mousewheel = document.all?"mousewhee>>>详细阅读
本文标题:js 判断浏览器类型 去全角、半角空格 自动关闭当前窗口
地址:http://www.17bianji.com/kaifa2/JS/28846.html
1/2 1