1
$(window).resize
不工作,我错过了什么?
所以我有一个350px宽度的垂直菜单,水平居中。链接打开显示不同内容的iframe。显示外部网站的iframe通过以下方式获取宽度:$("#iframeweb").width($(document).width() - $('#menu').width())
,以便填满屏幕,并将菜单推向旁边。
那部分工作,但它也需要改变窗口大小调整的宽度,但它什么都不做......
代码:
<div id="wrapper">
<div id="outer">
<div id="inner">
<iframe name="iframeweb" id="iframeweb"></iframe>
<div id="menu">
</div>
<iframe name="iframeA4" id="iframeA4"></iframe>
</div>
</div>
</div>
<script type="text/javascript">
$(window).resize(function() {
$("#iframeweb").width($(document).width() - $('#menu').width());
};
</script>
<script type="text/javascript">
$("#linkA4").click(function(){
$("#iframeA4")
.hide('fast')
.animate({"width": "0px"}, 'fast')
.animate({"width": "210mm"}, 'fast')
.show('fast');
$("#iframeweb").hide('fast');
});
$("#linkweb").click(function(){
$("#iframeA4")
.animate({"width": "0px"}, 'fast')
.hide('fast');
$("#iframeweb")
.hide('fast')
.width($(document).width() - $('#menu').width())
.show('fast');
});
</script>
那简单吗?!也许这只是休息的时间... – ThomasCS
:-P控制台/ Inspect元素是你最好的朋友,每当你做JS的时候,只要打开它就可以快速隔离语法错误,然后才能得到你最好的:) – Bryan