87,918
社区成员
发帖
与我相关
我的任务
分享
<script type="text/javascript">
function getAbsPos(oId, tl){
var o = ((typeof oId) == 'String') ? document.getElementById( oId ) : oId;
var val = 0;
while ( o.tagName.toLowerCase() != "body") {
val += (tl == 'top') ? parseInt( o.offsetTop ) : parseInt( o.offsetLeft );;
o = o.parentNode;
}
return val;
}
window.onload=function(){
var img = document.getElementById("img1");
var blank = document.getElementById("blank_img");
blank.width= img.width
blank.height= img.height
blank.style.top = getAbsPos(img, "top")
blank.style.left = getAbsPos(img, "left")
}
</script>
<body style="margin:0px;padding:0px">
<div><img id="img1" src="http://c.csdn.net/bbs/t/5/i/pic_logo.gif" ></div>
<img id="blank_img" src="http://www.chakucun.com/images/1x1.gif" style="position:absolute;z-index:1000;left:0;top:-100px;">
</body>