2012-05-14 19 views
0

我有一个网站,其中有一个部分包含Youtube视频及其评论。这是一个div类中的注释中使用下面的下面的代码得到刷新,每5分钟:jScrollPane在课堂刷新后重置为原始

<script type="text/javascript"> 
    setInterval(function(){ 
     $(".comments").load("test.php .comments"); 
    }, 300000); 
</script> 

要滚动的意见是由JScrollPane的供电。然而,在评论刷新之后,滚动器消失并且回复到原始浏览器滚动器。我已经尝试调整上面的脚本,以便刷新滚动条,但没有希望。

容器的意见是如下图所示

echo '<div class="comments scroll">'; 

     $feedURL = curl_init("http://gdata.youtube.com/feeds/api/videos/{$cut}/comments"); 
      curl_setopt($feedURL, CURLOPT_RETURNTRANSFER, true); 
      curl_setopt($feedURL, CURLOPT_HEADER, 0); 

     $data = curl_exec($feedURL); 
      curl_close($feedURL); 

     $sxml = new SimpleXmlElement($data);    

     foreach($sxml->entry as $comment) 
      { 
      echo '<p>',$comment->content,'</br><i>',$comment->author->name,'</i></br>','</p>'; 
      } 
    echo '</div>'; 

可能有人请就如何解决此错误。提前致谢。

回答

1
<script type="text/javascript"> 
    setInterval(function(){ 
     $(".comments").load("test.php"); 

     $('.scroll').jScrollPane(); 
    }, 300000); 
</script> 
+0

这可以防止滚动程序恢复为默认浏览器样式,但是不会再次刷新注释,它会将整个站点加载到注释框中 – Lodder

0

感谢@ ThulasiRam的想法,终于解决了它。尽管做了一些小改动。

<script type="text/javascript"> 
    setInterval(function(){ 
     $(".comments").load("test.php .comments"); 
     $('.scroll').jScrollPane({showArrows:true}); 
    }, 300000); 
</script>