3

我有下面的功能,在所有浏览器上都可以正常工作。但是,该功能(本质上用于注销用户)在 iPad(v3) 上不起作用。请注意,这是一个网络应用程序。

我最初的想法是它window.location,我听说它在 iPad 上运行不佳。但我试过了location.hrefwindow.location.href也无济于事。

没有控制台错误或奇怪的行为。

有人遇到过类似的问题吗?

$(document).on('touchstart click', '.sb-sign-out', function (e) {
    e.stopPropagation(); e.preventDefault();
    $.post('@Url.Action("clientLogout", "master")', {}, function () {
        window.location = "@Url.Action("campaigns", "master")";
    });
});

这是DIV:

<div class="sb-sign-out button round">LOGOUT</div>
4

2 回答 2

2

正如上面评论中提到的,这个问题是所有非 a-href 按钮都应该使用touchendvs touchstart。这解决了我的问题。

$(document).on('touchend click', '.sb-sign-out', function (e) {
    e.stopPropagation(); e.preventDefault();
    $.post('@Url.Action("clientLogout", "master")', {}, function () {
        window.location = "@Url.Action("campaigns", "master")";
    });
});
于 2013-10-28T18:01:12.410 回答
1

我认为使这项工作可靠的最佳方法是通过 jquery mobile 中的 'tap' 事件处理程序,例如: $(document).on('click tap', elem, function (e) {});

见这里:http ://api.jquerymobile.com/tap/

对于普通的 jquery,这个插件会给你同样的能力: http: //plugins.jquery.com/tap/

touchend 的问题是,如果有人触摸了按钮,然后决定不注销并将手指从按钮上移开,它会被触发,尽管不想要......

于 2013-10-30T18:04:39.727 回答