对于rightpos,leftpos和middlepos div,我使用以下代码具有相等的高度:
<script> jQuery.noConflict(); jQuery(document).ready(function($){ // Find the greatest height: maxHeight = Math.max($('#rightpos').height(),$('#middlepos').height()); maxHeight = Math.max(maxHeight,$('#leftpos').height()); // Set height: $('#rightpos').height(maxHeight); $('#middlepos').height(maxHeight); $('#leftpos').height(maxHeight); }) </script>
使用这种方式确定http://yaskawa.ir/主页的最高div在Firefox中运行良好,但在Chrome中有问题.
Sparky672的回答后更新1:
我可以看到,使用这段代码,警报(‘test here’);最后不行.
<script> jQuery.noConflict(); //jQuery(document).ready(function($){}); jQuery(window).load(function($){ // Find the greatest height: maxHeight = Math.max($('#rightpos').height(),$('#leftpos').height()); // Set height: $('#rightpos').height(maxHeight); $('#middlepos').height(maxHeight); $('#leftpos').height(maxHeight); alert('test here'); }) </script>
解决方法
尝试使用window.load()代替document.ready(),以确保在计算高度之前加载所有资源.
jQuery(window).load(function($){
文档:
The load event is sent to an element when it and all sub-elements have
been completely loaded. This event can be sent to any element
associated with a URL: images,scripts,frames,iframes,and the
window object.
http://api.jquery.com/load-event/
见演示: