mirror of
https://github.com/Mibew/design.git
synced 2025-01-24 02:50:33 +03:00
31 lines
701 B
JavaScript
31 lines
701 B
JavaScript
|
var myAgent = "";
|
||
|
var myVer = 0;
|
||
|
var myRealAgent = "";
|
||
|
|
||
|
function detectAgent() {
|
||
|
var AGENTS = ["opera","msie","safari","firefox","netscape","mozilla"];
|
||
|
var agent = navigator.userAgent.toLowerCase();
|
||
|
for (var i = 0; i < AGENTS.length; i++) {
|
||
|
var agentStr = AGENTS[i];
|
||
|
if (agent.indexOf(agentStr) != -1) {
|
||
|
myAgent = agentStr;
|
||
|
if (!window.RegExp)
|
||
|
break;
|
||
|
|
||
|
var versionExpr = new RegExp(agentStr + "[ \/]?([0-9]+(\.[0-9]+)?)");
|
||
|
if (versionExpr.exec(agent) != null) {
|
||
|
myVer = parseFloat(RegExp.$1);
|
||
|
}
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
myRealAgent = myAgent;
|
||
|
if( navigator.product == "Gecko")
|
||
|
myAgent = "moz";
|
||
|
}
|
||
|
detectAgent();
|
||
|
|
||
|
function getEl(name) {
|
||
|
return document.getElementById(name);
|
||
|
}
|