在窗口滑动时重定向到其他页面

Redirect to other page on swipe at window

本文关键字:其他 重定向 窗口      更新时间:2023-09-26

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

我包括了这两个文件:

<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页面