我加载了一个带有网站另一个页面内容的彩盒模式(官方演示中的 AJAX 示例)。此页面有一个显示更多
按钮,单击该按钮会显示更多内容。我还添加了额外的代码来尝试调整模式的大小以显示所有内容。
代码:
$("#button_writereview").colorbox.resize();
$("#button_writereview").colorbox.resize({innerWidth:560, innerHeight:750});
$("#button_writereview").colorbox.resize({Width:560, Height:750});
$.colorbox.resize();
$.colorbox.resize({innerWidth:560, innerHeight:750});
$(this).colorbox.resize();
$.fn.colorbox.resize();
$('#button_writereview').css('height',500);
上面的代码除了抛出错误之外没有做任何事情Uncaught TypeError: Cannot call method 'resize' of undefined
我似乎无法弄清楚调整大小!我猜这是从模式中的点击事件调用父页面的问题。
最佳答案
可能存在 jquery 冲突,因为每个人都喜欢
$
无论如何,您可以使用 jQuery noConflict 像<script type="text/javascript" src"/Scripts/jquery-1.6.2.min.js"></script> <script type="text/javascript"> jq = jQuery.noConflict(true); </script>
现在使用jq
而不是$
将代码包装在里面
$(函数(){
});
确保 jquery.js 和 colorbox.js 均已加载,有时它们包含在页眉中但未加载...
关于javascript - 调整 Colorbox 大小不起作用!,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6796594/