在Firefox、WebKit和Internet Explorer中插入窗口调整大小事件的正确(现代)方法是什么?
你能同时打开/关闭两个滚动条吗?
在Firefox、WebKit和Internet Explorer中插入窗口调整大小事件的正确(现代)方法是什么?
你能同时打开/关闭两个滚动条吗?
当前回答
jQuery默认提供了$(window).resize()函数:
<script type="text/javascript">
// function for resize of div/span elements
var $window = $( window ),
$rightPanelData = $( '.rightPanelData' )
$leftPanelData = $( '.leftPanelData' );
//jQuery window resize call/event
$window.resize(function resizeScreen() {
// console.log('window is resizing');
// here I am resizing my div class height
$rightPanelData.css( 'height', $window.height() - 166 );
$leftPanelData.css ( 'height', $window.height() - 236 );
});
</script>
其他回答
我认为你应该进一步控制这个:
var disableRes = false;
var refreshWindow = function() {
disableRes = false;
location.reload();
}
var resizeTimer;
if (disableRes == false) {
jQuery(window).resize(function() {
disableRes = true;
clearTimeout(resizeTimer);
resizeTimer = setTimeout(refreshWindow, 1000);
});
}
使用jQuery 1.9.1我刚刚发现,虽然技术上相同)*,这在IE10中不工作(但在Firefox中):
// did not work in IE10
$(function() {
$(window).resize(CmsContent.adjustSize);
});
虽然这在两种浏览器中都有效:
// did work in IE10
$(function() {
$(window).bind('resize', function() {
CmsContent.adjustSize();
};
});
编辑: )*实际上在技术上并不相同,正如WraithKenny和Henry Blyth在评论中所指出和解释的那样。
jQuery默认提供了$(window).resize()函数:
<script type="text/javascript">
// function for resize of div/span elements
var $window = $( window ),
$rightPanelData = $( '.rightPanelData' )
$leftPanelData = $( '.leftPanelData' );
//jQuery window resize call/event
$window.resize(function resizeScreen() {
// console.log('window is resizing');
// here I am resizing my div class height
$rightPanelData.css( 'height', $window.height() - 166 );
$leftPanelData.css ( 'height', $window.height() - 236 );
});
</script>
$(window).bind('resize', function () {
alert('resize');
});
既然你是开放的jQuery,这个插件似乎做的把戏。