Home >Web Front-end >JS Tutorial >js code to determine browser type and version number_javascript skills
phpnew blog has a built-in discuz ubb type editor. The editor function includes inserting at the cursor, but it has always been inaccurate on ie11.
After analyzing it today, I finally found the reason. Browse the old version of the js file written There is an abnormality in the processor's judgment, so the insertion point is always at the head. It will be fixed today.
Provide a js function. Return an array.
var match = rMsie.exec(ua);
if (match != null) {
return { browser : "ie", version : match[2] || "0" };
}
if (!!window.ActiveXObject || "ActiveXObject" in window){
return { browser : "ie", version : "0"};
}
var match = rFirefox.exec(ua);
if (match != null) {
return { browser : "firefox", version : match[2] || "0" };
}
var match = rOpera.exec(ua);
if (match != null) {
return { browser : "opera", version : match[2] || "0" };
}
var match = rChrome.exec(ua);
if (match != null) {
return { browser : "chrome", version : match[2] || "0" };
}
var match = rSafari.exec(ua);
if (match != null) {
return { browser : "safari", version : match[1] || "0" };
}
if (match != null) {
return { browser : "", version : "0" };
}
}
Hope it is helpful to everyone.
The content modified by the editor also fixes the problem of frequent failure to load attachment flash and solves the carriage return problem.