简体   繁体   English

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

[英]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 我正在使用此代码来放置外部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 当页面加载时,而不是将HTML放入ID为topdiv的div中,它只是重新加载整个页面并放置新的html而不是我的index.html

the external html just has a twitter widget from the official twitter website in a div 外部html只是具有来自div的官方twitter网站的twitter小部件

<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. 每毫秒重新加载页面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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