phpnew blog内置discuz ubb类型的编辑器, 编辑器功能上有在光标处插入, 可在ie11上一直不准确.
今天分析一下, 终于找到原因. 旧版本的js文件写的浏览器判断有异常, 所以导致插入点一直在头部. 今天修复之.
提供一个js函数. 返回一个数组.
复制代码 代码如下:
function sys_userAgent(){
var userAgent = navigator.userAgent,
rMsie = /(msie\s|trident.*rv:)([\w.]+)/,
rFirefox = /(firefox)\/([\w.]+)/,
rOpera = /(opera).+version\/([\w.]+)/,
rChrome = /(chrome)\/([\w.]+)/,
rSafari = /version\/([\w.]+).*(safari)/;
var browser,version,ua;
ua = userAgent.toLowerCase();
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" };
}
}