当正文调整大小时,IE在调整大小时启动

IE fires onresize when body resizes

本文关键字:调整 小时 启动 IE 正文      更新时间:2023-09-26

我有以下功能-它在Firefox中运行良好:

如何在IE中调整主体大小时启用此功能??

function sizeColumnHeadings() {
    var $headingsTable = $('#TopicPostList_hdiv > table').eq(0),
        $rowsTable = $('#TopicPostList_div > table').eq(0);
    if ($headingsTable.length && $rowsTable.length) {
        $headingsTable.width($rowsTable.width());
    }
}


$(window).on('resize', function() {
        sizeColumnHeadings();
    }).trigger('resize');

如果您使用jquery,我发现以下代码适用于IE、Firefox和Chrome。

var cnt = 0;
// this is called when the document finishes loading (similar to onLoad in the body tag)
$(function() {
    // this asssigns a callback function each time the browser is resized
    // it turns out that it is triggered multiple times on one resize
    $(window).resize(function() {
        cnt++;
        // this code simply displays the # of times the callback is triggered
        // I defined a <div id=show> in the body, and this updates its html.
        $('#show').html('cnt = ' + cnt);
    });
});

我建议使用jquery来解决这类问题,因为它经常会处理不同浏览器之间的不兼容问题。