我对jQuery没有太多的经验。
我需要在更改浏览器窗口时动态设置<frameset>的<frameset>属性。
这是我的框架集:<FRAMESET BORDER='0' ROWS="112,*" id='reSizeWindow'>
我使用的jQuery是:
$('#reSizeWindow').css('rows', $(window).height()+50+'px');这不管用,所以我用:
<script>
window.onresize = function() {
var widthViewport = window.innerWidth || document.body.clientWidth;
var el = document.getElementById('reSizeWindow');
if( widthViewport < 1000 ) {
el.setAttribute();
el.rows = '108'
} else {
el.rows = '100%';
}
};
</script>在这里,我得到的错误如下:
el为空
请帮助我获得一个工作的javascript / jQuery。
发布于 2013-12-20 09:11:37
尝尝这个
$(document).ready(function () {
$(window).on('resize', function(){
var win = $(this); //this = window
if (win.height() <= 1000)
{
parent.document.getElementsByTagName( 'frameset' )[ 0 ].rows = '108,*'
}
else { parent.document.getElementsByTagName( 'frameset' )[ 0 ].rows = '150,*' }
});
});发布于 2013-12-20 10:22:14
下面的代码在Sridhar R的帮助下为我工作。
<script type="text/javascript" language="javascript">
$(document).ready(function () {
$(window).on('resize', function(){
var win = $(this);
if (win.width() <= 1000) { // width() and not height()
parent.document.getElementsByTagName( 'frameset' )[ 0 ].rows = '150,*';
} else {
parent.document.getElementsByTagName( 'frameset' )[ 0 ].rows = '108,*';
}
});
});
</script>https://stackoverflow.com/questions/20699894
复制相似问题