Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 尝试在加载时加载页面而不是单击_Javascript_Jquery_Load - Fatal编程技术网

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);
    });
    });
    
    如果用户第一次看到页面时需要它,那么最好在服务器端这样做,有什么原因不适合这种情况吗?如果用户第一次看到页面时需要它,最好在服务器端这样做,有什么原因不适合这种情况吗?