最近我发现通过script
动态地将图像添加到网站。这会在页脚下方创建一个空白区域。
动态添加的代码是:
<script type="text/javascript" async="">
var xl8image = document.createElement("img");
xl8image.src = "http://load77.exelator.com/pixel.gif";
xl8image.width="0";
xl8image.height="0";
document.body.appendChild(xl8image);
</script>
我最初的疑问是我使用的chrome扩展。当我测试删除扩展时,我发现它仍然存在!还要确保它是否发生在IE,Firefox等其他浏览器中。
任何人都可以帮我找到删除空白区域?我的解决方案没有此文件或其参考。
使用position: absolute
将元素绝对定位,以将其从正常文档流中移除。这样可以防止它在页面上造成间隙。
新代码:
<script type="text/javascript" async="">
var xl8image = document.createElement("img");
xl8image.src = "http://load77.exelator.com/pixel.gif";
xl8image.width = "0";
xl8image.height = "0";
xl8image.style.position = "absolute"; //add this
document.body.appendChild(xl8image);
</script>