我有以下功能-它在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');发布于 2012-03-26 00:57:35
如果你使用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来解决这类问题,因为它通常会处理不同浏览器之间的不兼容性。
https://stackoverflow.com/questions/9859485
复制相似问题