如果用户向左滑动,我会尝试重定向到另一个页面。
我包含了这两个文件:
<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页面中
关于javascript - 在窗口滑动时重定向到其他页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36982791/