1

我目前正在尝试在我的 tumblr 博客上安装此自定义滚动条:http ://manos.malihu.gr/jquery-custom-content-scroller/ 在我 向我的博客和我的整个博客中添加文本命中计数器之前,这一切都运行良好内容消失了。

这是自定义滚动条的 jQuery:

<script>
$(document).ready(function() {
     $('body').mCustomScrollbar({
        theme: 'dark-thin',
        scrollButtons: true,
    });      
});
</script> 

这是文本命中计数器的脚本:

<script language="JavaScript">
    var fhsh = document.createElement('script');
    var fhs_id_h = "2423608";
    fhsh.src = "http://freehostedscripts.net/ocount.php?site="+fhs_id_h+"&name= &a=1";
    document.head.appendChild(fhsh);
    document.write("<span id='h_"+fhs_id_h+"'></span>");
</script>

我很确定这是导致问题的“document.write”方法。但是不知道有没有办法解决这个问题?任何帮助都感激不尽。

4

1 回答 1

1

问题确实是您使用document.write. 应尽可能避免。

相反,您可以使用 jQuery 添加- 只需确保在事件触发span后运行此代码:readydocument

$('body').append('<span id="h_' + fhs_id_h + '"></span>');
于 2017-04-20T07:28:39.387 回答