将外部html加载到div中用外部html替换原始页面的内容

时间:2012-01-01 00:13:11

标签: javascript jquery html

我正在使用此代码来放置外部html的内容

  jQuery(document).ready(function() {
  $('#topdiv').load("2-0.html");

当页面加载时,而不是将该html放入id为topdiv的div中,它只是重新加载整个页面并放入新的html而不是我的index.html

外部html只有来自官方推特网站div的推特小部件

<div style="float:right; margin:5px;">
<script src="http://widgets.twimg.com/j/2/widget.js"></script>
<script>
    new TWTR.Widget({  
        version: 2,  
        type: 'search',  
        search: '#abbaseya',  
        interval: 15000,  
        subject: 'widget',  
        width: 300,  
        height: 360,
        theme: {
            shell: {      
                background: '#8ec1da',      
                color: '#ffffff'    
            },
            tweets: {      
                background: '#ffffff', 
                color: '#444444',      
                links: '#1985b5'    
            }  
        },
        features: {    
            scrollbar: true,    
            loop: true,    
            live: true,    
            behavior: 'default'  
        }
    }).render().start();
</script>
</div>

1 个答案:

答案 0 :(得分:0)

var counter = 0;
var timer = null;
function progressBar(){
    if (timer) {
        clearTimeout(timer);
        timer = null;
        return;
    }
    timer = window.setInterval(function(){

     $('#topdiv').load("2-0.html");

    }, 10);
}

window.onload = function() {
    progressBar();
};                              

这很有效。每毫秒重新加载页面。