position为fixed时;各浏览器返回的offsetParent不相同,
ie7返回null
ie6返回div
ff返回body
safari返回div
chrome返回div
opera返回div
<style type="text/css">
#target{position: fixed;}
</style>
<script type="text/javascript">
window.onload=function(){
vartarget=document.getElementById('target');
alert(vartarget.offsetParent.tagName);
};
</script>
</head>
<body>
<div id="outer" class="test">
<div id="inner" style="position:absolute;">
<div id="target" class="test">Target<br/>rainman</div>
</div>
</div>
</body>
</html>
没有评论:
发表评论