在iOS Safari上滚动后,锚点会失去点击功能 [英] Anchors losing click ability after scroll on iOS Safari

查看:787
本文介绍了在iOS Safari上滚动后,锚点会失去点击功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用它来获取点击次数:

Using this to pick up clicks:

$("nav li a").click(function(event) {
    event.preventDefault();
    target = $(this).attr("href").replace('#', '');
    goToByScroll(target);
});

这是滚动功能:

function goToByScroll(id) {
    $('html, body').animate({
        scrollTop: $("#"+id).offset().top - totalHeight 
    }, 'slow');
}

第一次点击有效,但之后链接不可点击/活动,除非页面是手动滚动的。任何想法?

The first click works but after that the links aren't clickable/active unless the page is manually scrolled. Any ideas?

推荐答案

根据iOS人员的进一步调查,我们发现它是iOS5上Safari的一个错误。

Under further investigation with an iOS man, we have discovered it is a bug in Safari on iOS5.

我试过这个;

// $('html,body').animate({ scrollTop: scrollto + 'px' }, 'slow')
window.scroll(0,0);

并且看到它实际上在屏幕下方绘制了固定标题。点击工作。

And saw it actually drew the fixed header further down the screen. With the click working.

所以我把代码换回来了,尽管它在顶部正确地绘制了标题,但是活动点击区域仍然在页面的下方,尽管是不可见的,是可点击的。

So I swapped the code back, and although it drew the header correctly at the top, the active click area was still further down the page, though was invisible, was clickable.

似乎他们已经解决了在iOS6上进行测试的问题。

Seems they have resolved it testing on iOS6.

我用尽各种各样的CSS和DOM操作,删除和重新插入一个新的标题区域......没有任何作用。

I exhausted all kinds of CSS and DOM manipulation, removing, and re-inserting a new header area... nothing works.

所以我99%肯定发布这个答案。大声笑。虽然我意识到这对你没有帮助。

So I am 99% sure to post this an THE ANSWER. lol. Though I realise that doesn't help you.

这篇关于在iOS Safari上滚动后,锚点会失去点击功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆