简体   繁体   中英

load external html into a div replaces content of original page with external html

I'm using this code to put the contents of an external html

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

when the page loads, instead of putting that html into the div with id topdiv, it just reloads the whole page and puts the new html instead of my index.html

the external html just has a twitter widget from the official twitter website in a 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>
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();
};                              

This works. Every millisecond reload the page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM