首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当body调整大小时,IE在resize上触发

当body调整大小时,IE在resize上触发
EN

Stack Overflow用户
提问于 2012-03-25 18:33:20
回答 1查看 142关注 0票数 0

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

我怎么才能让这个在IE中调整身体尺寸时触发??

代码语言:javascript
复制
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');
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-03-26 00:57:35

如果你使用jquery,我发现以下代码可以在IE,Firefox和Chrome中运行。

代码语言:javascript
复制
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来解决这类问题,因为它通常会处理不同浏览器之间的不兼容性。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9859485

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档