貌似是chrome在ubuntu下的一个bug

来源:互联网 发布:淘宝代理加盟靠谱吗 编辑:程序博客网 时间:2024/05/01 04:07

假设有如下两个页面:

1.html

<!doctype html><html>    <head><title>test</title>    <meta http-equiv="Content-Type" content="text/html charset=utf-8" />    </head>    <body>    <a href="test.html" target="blank">测试</a>    </body></html>

test.html

<!doctype html><html>    <head>    <title>test page</title>    <meta http-equiv="Content-Type" content="text/html charset=utf-8" />    <script src="jquery-1.6.2.js" type="text/javascript"></script>    <script type="text/javascript">    (function(){        $(document).ready(function(){            //console.log($(window).height());            $('#a').append('<p>' + $(window).height() + '</p>');            setTimeout(function(){                //console.log($(window).height());                $('#a').append('<p>' + $(window).height() + '</p>');            }, 100);        });    })();    </script>    </head>    <body>    <div id="a"></div>    </body></html>



将两个网页源码保存命名后放到同一个目录下,并嵌入相应jquery,如果单独用chrome打开test.html,页面会正确显示两次页面的可视高度值,但是如果从1.html页面的测试链接跳转到test.html这个页面,页面显示的第一个可视高度值是0,第二个正确,可能是由于chrome在渲染DOM时候的问题,算是bug吧。

PS.修改那个setTimeout的第二个参数值,让它变小,chrome可能会出现更神奇的现象。

PS.同样使用webkit的safari,测试正常,而且在windows下使用chrome测试本实例,结果也正确。