在Edge模式下,JQuery tablesorter pager插件无法与IE11一起正常工作

如果您使用Tablesorter Jquery插件与页面上的分页器添加将不会显示任何数据。 数据存在,但它是隐藏的。

我怀疑该插件的浏览器function检测方法无法处理IE11。

其他人遇到这个?

IE11似乎与他的userAgent有问题。 一个转变是改变clearTableBody函数(在jquery.tablesorter-2.0.3.js中工作),如下所示:

this.clearTableBody = function (table) { //if ($.browser.msie) { function empty() { while (this.firstChild) this.removeChild(this.firstChild); } empty.apply(table.tBodies[0]); //} else { // table.tBodies[0].innerHTML = ""; //} }; 

这是因为Internet Explorer 11具有不包含“MSIE”的用户代理字符串,因此jQuery无法正确识别它(请参阅此问题 )。

但实际上,TableSorter 呼叫器 代码不需要知道哪个浏览器正在运行代码。 更改函数clearTableBody以改为使用jQuery的跨浏览器实现:

 this.clearTableBody = function(table) { $(table.tBodies[0]).empty(); }; 

我在IE8,IE9,IE11,Chrome 31和Firefox 24中测试了这个。

(刚才,我找到了一个带有TableSorter分支的GitHub仓库,它可能已经解决了这个问题: https : //github.com/Mottie/tablesorter )

我们有同样的问题。 我已经直接向微软提交了一张票。

等着瞧…

https://connect.microsoft.com/IE/feedback/details/806279/bug-when-sorting-with-a-jquery-plugin

一个简单的解决方案 – 将jquery.tablesorter.js中的行从if($.browser.msie)更改为:

if(/msie/.test(navigator.userAgent.toLowerCase()) || window.navigator.userAgent.indexOf("Trident/7.0") > 0)适合我。

/msie/.test(navigator.userAgent.toLowerCase())检测IE 10或更低版本。 window.navigator.userAgent.indexOf("Trident/7.0") > 0检测到IE 11。