如果当前页面为X,请执行此操作

If current page is X, do this action

本文关键字:执行 操作 当前页 如果      更新时间:2023-12-03

我有一个简单的网站,在将内容带到URL之前,它会将内容从页面上滑下。然而,我需要能够确定滑动方向,这取决于你当前所在的页面

我需要这样做,但我不确定如何用jQuery:正确地表达它

if (current page == about.php) {
   animate right then go to target URL }
else {
 do default behaviour }

目前,我有一个功能不太好用,因为无论你要使用哪个URL,它都会以某种方式进行动画处理:

function animateLeftAndGo(x) {
        $(x).click(function (e) {
        e.preventDefault();
        var href = this.href;
        $('.pop-up').fadeOut(function(){
        $('.wrapper').animate({left: "+=150%"}, "slow", function(){
            window.location = href;
            });
        });
    });
}

其名称为:

animateLeftAndGo('a.archive');

如何设置询问当前URL是否为about.phpif statement

在JavaScript中使用location对象:http://www.w3schools.com/jsref/obj_location.asp

if(location.pathname==''){}