Internet Explorer 9 not rendering table cells properly

后端 未结 14 2069
借酒劲吻你
借酒劲吻你 2020-11-28 02:18

My website has always run smoothly with IE8, IE7, FF, Chrome and Safari. Now I\'m testing it on IE9 and I\'m experiencing a strange problem: in some pages, some tabular data

相关标签:
14条回答
  • 2020-11-28 03:10

    The solution given @Shanison helps only partially but the problem persists if there are spaces between any of the other elements that can be part of the table content model like thead, th etc.

    Here is a better regex devised by my Lead at work.

    if (jQuery.browser.msie && jQuery.browser.version === '9.0')
    {
        data = data.replace(/>\s+(?=<\/?(t|c)[hardfob])/gm,'>');
    }
    

    covering all table, caption, colgroup, col, tbody, thead, tfoot, tr, td, th elements.

    Note: jQuery.browser was removed in jQuery 1.9 and is available only through the jQuery.migrate plugin. Please try to use feature detection instead.

    0 讨论(0)
  • 2020-11-28 03:12

    I had this problem sometimes on tables generated by Knockout. In my case I fixed it using the jQuery solution found here

    jQuery.fn.htmlClean = function() {
        this.contents().filter(function() {
            if (this.nodeType != 3) {
                $(this).htmlClean();
                return false;
            }
            else {
                this.textContent = $.trim(this.textContent);
                return !/\S/.test(this.nodeValue);
            }
        }).remove();
        return this;
    }
    
    0 讨论(0)
提交回复
热议问题