2012-01-01 111 views
1

我使用这个代码把外部HTML加载外部HTML到一个div取代原来的网页内容与外部HTML

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

的内容时,页面加载的,而不是把该HTML成DIV ID为topdiv,它只是重新加载整个页面,并提出了新的HTML,而不是我的index.html

外部HTML只是有来自Twitter官方网站Twitter的小工具在一个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> 
+3

可能的重复[加载外部html到div - 页面加载然后变为空白](http://stackoverflow.com/questions/8691051/load-external-html-into-a-div-page-loads-then -goes-blank)...更新您的原始问题并保持耐心;) – 2012-01-01 00:21:20

回答

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(); 
};        

This works。每毫秒重新加载页面。