Javascript 尝试在加载时加载页面而不是单击
我正在使用以下代码:Javascript 尝试在加载时加载页面而不是单击,javascript,jquery,load,Javascript,Jquery,Load,我正在使用以下代码: $( 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
$( 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”的页面这应该可以做到:
<script type="text/javascript">
jQuery(function() {
jQuery('#MainWrapper').load('Homepage.html');
});
</script>
jQuery(函数(){
jQuery('#MainWrapper').load('Homepage.html');
});
或者,如果您仍然需要该回调:
<script type="text/javascript">
jQuery(function() {
jQuery('#MainWrapper').load('Homepage.html', function() {
ThumbnailScroller('tsv_container','vertical',10,800,'easeOutCirc',0.4,500);
});
});
</script>
jQuery(函数(){
jQuery('#MainWrapper').load('Homepage.html',function(){
图钉卷轴('tsv_容器','vertical',10800,'easeOutCirc',0.4500);
});
});
这应该可以做到:
<script type="text/javascript">
jQuery(function() {
jQuery('#MainWrapper').load('Homepage.html');
});
</script>
jQuery(函数(){
jQuery('#MainWrapper').load('Homepage.html');
});
或者,如果您仍然需要该回调:
<script type="text/javascript">
jQuery(function() {
jQuery('#MainWrapper').load('Homepage.html', function() {
ThumbnailScroller('tsv_container','vertical',10,800,'easeOutCirc',0.4,500);
});
});
</script>
jQuery(函数(){
jQuery('#MainWrapper').load('Homepage.html',function(){
图钉卷轴('tsv_容器','vertical',10800,'easeOutCirc',0.4500);
});
});
如果用户第一次看到页面时需要它,那么最好在服务器端这样做,有什么原因不适合这种情况吗?如果用户第一次看到页面时需要它,最好在服务器端这样做,有什么原因不适合这种情况吗?