2

jquery.append()我使用 ajax 和使用本教程实现了无限滚动。在 ajax 成功时,jquery 将十个<li>元素附加到<ul>.

滚动在 Chrome 和 Firefox 上运行正常(可能更快?),但在滚动后会导致 IE 崩溃。关于如何避免崩溃 IE 并可能提高性能的任何建议?

一个<li>元素包含以下内容:

<div class="post_div" align="left">
 <div class="separator_div"></div>
   <table class="post_table" align="left">
     <tr><!--header e.g title-->
    <td class="td_first1"><!--title-->
        Title
    </td>
    <td class="td_second1"><!--blank-->
    </td>
     </tr>

     <tr><!--middle e.g picture-->
    <td  class="td_first2"><!--picture-->
         <img class="img" id="49130" width="480" height="360" src="pic.jpg"></img>
    </td>
          <td class="td_second2"><!--user,text,vote,share-->
         <div class="user_div"><!--avatar+username-->
             <img class="uavatar" src="avatar.jpg"></img>
             <a href="link/user.php?u=2"><span class="user_span">Jon Doe</span></a>
        </div>
        <div class="text_div"><!--text-->
        some text....
        </div>
       <div class="vote_div"><!--vote-->
        <table align="left" width="220">
                      3coloumsx2rows table here
                    </table>
       </div>
       <div class="share_div"><!--share-->
        2 iframes here          
       </div>
     </td>
    </tr>

    <tr><!--bottom e.g desc-->
    <td class="td_first3"><!--desc-->
    <div class="desc_div">
             onother text here....
    </div>
    </td>
    <td class="td_second3"><!--time+views-->
    0 views  1 second ago
    </td>
    </tr>
    </table>
</div>
4

1 回答 1

0

还需要查看您的 javascript 代码。

要记住的一件事是 IE 在您滚动时触发“滚动”事件,而其他浏览器则等到滚动结束。结果是您在“滚动”事件中所做的任何事情都会在您滚动时不断执行,因此当您说要添加 10 个 LI 时,您实际上是在几秒钟内添加了 100 个。

对此的解决方案是设置超时以在滚动时执行 ajax 请求。如果用户继续滚动,超时将被清除并重置。当用户停止滚动时,超时完成并调用您的 ajax 请求函数。

于 2012-09-17T14:04:39.900 回答