function getExplorer(){ var browser; var explorer = window.navigator.userAgent ; var a1 = navigator.userAgent; var yesIE = a1.search(/Trident/i);//判断IE var IE = a1.search(/rv:11.0/i);//判断IE 11 if(IE>0){ return browser = 'ie11'; }else //ie if (yesIE > 0) { return browser = 'ie'; } //Edge else if(explorer.indexOf("Edge") >= 0){ return browser = 'Edge'; } //firefox else if (explorer.indexOf("Firefox") >= 0) { return browser = 'Firefox'; } //Chrome else if(explorer.indexOf("Chrome") >= 0){ return browser = 'Chrome'; } //Opera else if(explorer.indexOf("Opera") >= 0){ return browser = 'Opera'; } //Safari else if(explorer.indexOf("Safari") >= 0){ return browser = 'Safari'; } }