【问题标题】:load77.exelator.com/pixel.gif is causing a white space below the footerload77.exelator.com/pixel.gif 导致页脚下方出现空白
【发布时间】:2018-06-02 02:48:17
【问题描述】:

最近我观察到一张图片是通过 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)中发生。

谁能帮我找到有关删除空白的信息?我的解决方案没有这个文件,也没有它的参考。

【问题讨论】:

    标签: javascript html css


    【解决方案1】:

    使用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>
    

    【讨论】:

    • 我很想知道为什么要添加它?
    • 这是来自 Nielsen 的跟踪像素。
    • 很高兴知道。以前从未听说过。但我现在知道了。谢谢@lupos
    猜你喜欢
    • 1970-01-01
    • 2023-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-10
    • 2016-08-09
    • 1970-01-01
    相关资源
    最近更新 更多