在 window 滑动重定向到其他页面

Redirect to other page on swipe at window

如果用户向左滑动,我会尝试重定向到另一个页面。

我包含了这两个文件:

<script src="js/jquery-2.2.3.min.js"></script>
<script src="js/jquery.mobile-1.4.5.min.js"></script>

我这样试过:

$(document).ready(main);

function main()
{
    $("window").on( "swipeleft", swipeleftHandler );

    function swipeleftHandler( event )
    {
        window.location.href = "index.php";
    }
}

但是什么也没有发生。没有抛出任何错误。

试试这个:

<script>
$(function(){
    $( "body" ).on( "swipeleft", swipeleftHandler );

    function swipeleftHandler( event ){
    window.location.href = "index.php";
    }
});
</script>



不在函数(main)中,在php页面