jQuery-如何在<;上启动函数;a>;在切换到herf之前

jQuery-如何在<;上启动函数;a>;在切换到herf之前,jquery,Jquery,我想创建一个平滑传输的网站。我这样做: $(document).ready(function () { "use strict"; $("html").hide(); $("html").fadeIn("slow"); ... 对于fadeIn,但现在我想以某种方式设置: ... $("a").click(function(){ $("html").fadeOut("slow"); }); ... 但我希望html在切换到下一个站点之前逐渐消失

我想创建一个平滑传输的网站。我这样做:

$(document).ready(function () {
    "use strict";
    $("html").hide();
    $("html").fadeIn("slow");
...
对于fadeIn,但现在我想以某种方式设置:

...
$("a").click(function(){
        $("html").fadeOut("slow");
    });
...
但我希望
html
在切换到下一个站点之前逐渐消失

我知道我可以这样做,就像我将所有
更改为
id
并通过jQuery创建链接一样,但我想寻求更简单的方法。

防止
默认操作并创建超时,然后重定向到
href
尝试以下方法:

$("a").click(function(e){
    e.preventDefault();
    var href = $(this).attr('href');
    $("html").fadeOut("slow");
    setTimeout(function(){
        window.location= href;
    }, 1000);
});
阻止
默认操作并创建超时,然后重定向到
href
尝试以下操作:

$("a").click(function(e){
    e.preventDefault();
    var href = $(this).attr('href');
    $("html").fadeOut("slow");
    setTimeout(function(){
        window.location= href;
    }, 1000);
});
阻止
默认操作并创建超时,然后重定向到
href
尝试以下操作:

$("a").click(function(e){
    e.preventDefault();
    var href = $(this).attr('href');
    $("html").fadeOut("slow");
    setTimeout(function(){
        window.location= href;
    }, 1000);
});
阻止
默认操作并创建超时,然后重定向到
href
尝试以下操作:

$("a").click(function(e){
    e.preventDefault();
    var href = $(this).attr('href');
    $("html").fadeOut("slow");
    setTimeout(function(){
        window.location= href;
    }, 1000);
});
用这个

$(document).ready(function () {
    "use strict";
    $("html").hide();
 setTimeout(function(){
         $("html").fadeIn("slow");
    }, 1000);
...

用这个

$(document).ready(function () {
    "use strict";
    $("html").hide();
 setTimeout(function(){
         $("html").fadeIn("slow");
    }, 1000);
...

用这个

$(document).ready(function () {
    "use strict";
    $("html").hide();
 setTimeout(function(){
         $("html").fadeIn("slow");
    }, 1000);
...

用这个

$(document).ready(function () {
    "use strict";
    $("html").hide();
 setTimeout(function(){
         $("html").fadeIn("slow");
    }, 1000);
...

试试这个

<a href='//link here' onclick='myFunction(event)'>

function myFunction(e)
{
var that = this;

// prevent fade from firing on mid-click
    e.preventDefault();

    $('html').fadeOut(2000, function(){
        window.location.href = that.href;
    });
}

函数myFunction(e)
{
var=这个;
//防止单击鼠标中键时发射淡入淡出
e、 预防默认值();
$('html').fadeOut(2000,function(){
window.location.href=that.href;
});
}
试试这个

<a href='//link here' onclick='myFunction(event)'>

function myFunction(e)
{
var that = this;

// prevent fade from firing on mid-click
    e.preventDefault();

    $('html').fadeOut(2000, function(){
        window.location.href = that.href;
    });
}

函数myFunction(e)
{
var=这个;
//防止单击鼠标中键时发射淡入淡出
e、 预防默认值();
$('html').fadeOut(2000,function(){
window.location.href=that.href;
});
}
试试这个

<a href='//link here' onclick='myFunction(event)'>

function myFunction(e)
{
var that = this;

// prevent fade from firing on mid-click
    e.preventDefault();

    $('html').fadeOut(2000, function(){
        window.location.href = that.href;
    });
}

函数myFunction(e)
{
var=这个;
//防止单击鼠标中键时发射淡入淡出
e、 预防默认值();
$('html').fadeOut(2000,function(){
window.location.href=that.href;
});
}
试试这个

<a href='//link here' onclick='myFunction(event)'>

function myFunction(e)
{
var that = this;

// prevent fade from firing on mid-click
    e.preventDefault();

    $('html').fadeOut(2000, function(){
        window.location.href = that.href;
    });
}

函数myFunction(e)
{
var=这个;
//防止单击鼠标中键时发射淡入淡出
e、 预防默认值();
$('html').fadeOut(2000,function(){
window.location.href=that.href;
});
}

如果不想用ajax加载新的html,请将其放入托盘中

$('a').click(function() {   
    event.preventDefault();    

    newLocation = this.href;

    $('body').fadeOut(1000, newpage);

    });

    function newpage() {    
        window.location = newLocation;    
    } 
});

如果不想用ajax加载新的html,请将其放入托盘中

$('a').click(function() {   
    event.preventDefault();    

    newLocation = this.href;

    $('body').fadeOut(1000, newpage);

    });

    function newpage() {    
        window.location = newLocation;    
    } 
});

如果不想用ajax加载新的html,请将其放入托盘中

$('a').click(function() {   
    event.preventDefault();    

    newLocation = this.href;

    $('body').fadeOut(1000, newpage);

    });

    function newpage() {    
        window.location = newLocation;    
    } 
});

如果不想用ajax加载新的html,请将其放入托盘中

$('a').click(function() {   
    event.preventDefault();    

    newLocation = this.href;

    $('body').fadeOut(1000, newpage);

    });

    function newpage() {    
        window.location = newLocation;    
    } 
});

您必须通过在单击回调中返回false来禁用链接开关,完成转换后,您应该在新位置转到重定向,如下所示:

$(文档).ready(函数(){


}))

您必须通过在单击回调中返回false来禁用链接切换,并且在完成转换后,您应该在新位置转到重定向,如下所示:

$(文档).ready(函数(){


}))

您必须通过在单击回调中返回false来禁用链接切换,并且在完成转换后,您应该在新位置转到重定向,如下所示:

$(文档).ready(函数(){


}))

您必须通过在单击回调中返回false来禁用链接切换,并且在完成转换后,您应该在新位置转到重定向,如下所示:

$(文档).ready(函数(){


}))

也许您可以在卸载之前使用
on
,但总的来说,我认为这是个坏主意。基本上,您正在减慢进程,延迟加载新页面,因此这将对用户体验产生负面影响。他们可能会“敬畏”一次或两次,之后,这会让他们感到烦恼。也许你可以使用
onbeforeuload
,但总的来说,我认为这是个坏主意。基本上,您正在减慢进程,延迟加载新页面,因此这将对用户体验产生负面影响。他们可能会“敬畏”一次或两次,之后,这会让他们感到烦恼。也许你可以使用
onbeforeuload
,但总的来说,我认为这是个坏主意。基本上,您正在减慢进程,延迟加载新页面,因此这将对用户体验产生负面影响。他们可能会“敬畏”一次或两次,之后,这会让他们感到烦恼。也许你可以使用
onbeforeuload
,但总的来说,我认为这是个坏主意。基本上,您正在减慢进程,延迟加载新页面,因此这将对用户体验产生负面影响。他们可能会“敬畏”一两次,之后,这会让他们感到烦恼。谢谢。您的解决方案工作正常,我只是将淡出速度更改为fast,并将超时设置为200,它工作正常。非常感谢,谢谢。您的解决方案工作正常,我只是将淡出速度更改为fast,并将超时设置为200,它工作正常。非常感谢,谢谢。您的解决方案工作正常,我只是将淡出速度更改为fast,并将超时设置为200,它工作正常。非常感谢,谢谢。您的解决方案工作正常,我只是将淡出速度更改为fast,并将超时设置为200,它工作正常。谢谢。