最近我观察到图像是通过脚本
动态添加到网站的。这会在页脚下方创建一个空白区域。
动态添加的代码是:
<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>
关于javascript - load77.exelator.com/pixel.gif 导致页脚下方出现空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47890841/