试图加载上的加载页面,而不是点击

问题描述:

我使用这个代码:试图加载上的加载页面,而不是点击

$(document).ready(function() { 
    $('a.dynamicLoad').click(function(e) { 
     e.preventDefault(); // prevent the browser from following the link 
     e.stopPropagation(); // prevent the browser from following the link 

     $('#MainWrapper').load($(this).attr('href') , function() { 
      /* Content is now loaded */ 
      ThumbnailScroller("tsv_container","vertical",10,800,"easeOutCirc",0.4,500); 
     }); 
    }); 
}); 

与此相伴:

<li><a href="Help.html" class="dynamicLoad">HELP</a></li> 

要链接被点击时加载的页面。

我想知道如何添加到当前的脚本,以便我可以在页面加载时加载页面,同时保持它现在的工作方式?我想加载一个名为“Homepage.html”页面

+0

一个更好的想法可能是如果在用户第一次看到它时在页面上需要它,那么在服务器端执行该操作,在这种情况下可能不适用的任何原因? – 2011-02-12 02:49:36

+0

我该怎么做? – WillingLearner 2011-02-12 11:20:28

这应做到:

<script type="text/javascript"> 
jQuery(function() { 
    jQuery('#MainWrapper').load('Homepage.html'); 
}); 
</script> 

或者,如果你仍然需要回调:

<script type="text/javascript"> 
jQuery(function() { 
    jQuery('#MainWrapper').load('Homepage.html', function() { 
     ThumbnailScroller('tsv_container','vertical',10,800,'easeOutCirc',0.4,500); 
    }); 
}); 
</script>