触发电子邮件叠加后iPhone jQuery中断 [英] iPhone jQuery breaks after triggering the email overlay

查看:84
本文介绍了触发电子邮件叠加后iPhone jQuery中断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jQuery为iPhone开发移动网站。我有一个隐藏的div(类 .tile-content ),它包含一些内容。点击 onclick =showContent(this)的链接会像这样调用fadeIn:

I'm developing a mobile site for iPhone using jQuery. I have a hidden div (class .tile-content) that holds some content. Clicking a link with onclick="showContent(this)" calls fadeIn like this:

        function showContent(obj)
        {
            alert($(obj).html());
            $(obj).next('.tile-content').fadeIn();
            return false;
        }

一切顺利,直到我点击发送电子邮件给我们,其中包含mailto:link在它上面,触发iPhone内置的电子邮件叠加功能。然后我点击取消并返回该网站。现在,如果我点击链接,我的 .tile-content div将不会显示。我虽然在iPhone上得到了适当的警报。在我按下一次后,没有任何作用(我认为这意味着有一个js错误?)。在物理iPhone上进行调试非常困难。有什么想法吗?

Everything works great until I tap "email us" which has a mailto: link on it, triggering the iPhone's built in email overlay functionality. I then hit cancel and am returned to the site. Now, if I click a link, my .tile-content div won't show up. I get the proper alert on the iPhone though. After I press that once, nothing works (which I think means there was a js error?). Having a really hard time debugging on a physical iPhone. Any ideas?

更新我启用了Safari Mobile的调试控制台,感谢@John Boker的提示。没有错误显示,但我仍然遇到同样的问题。

Update: I enabled Safari Mobile's debug console thanks to a tip from @John Boker below. No errors show up, but I'm still having the same problem.

推荐答案

问题出现在setInterval / setTimeout javascript函数中。在iPhone上的Safari中启动邮件窗口时,似乎暂停了用于这些功能的内部计时器。发送电子邮件(或点击取消)后,计时器将暂停,并且不会触发setTimeout / setInterval函数。

The problem occurs within the setInterval/setTimeout javascript functions. When launching the mail window within Safari on the iPhone it seems that the internal timer used for these functions is paused. After sending the email (or tapping cancel) the timer is left paused and the setTimeout/setInterval functions will not fire.

这将破坏任何依赖于setTimeout / setInterval的事情例如jquery动画和任何异步ajax调用,因为jquery使用setInterval进行轮询直到请求返回(我自己遇到了这个问题)。

This will break any thing that relies on setTimeout/setInterval such as jquery animations and any async ajax calls since jquery uses setInterval to poll until the request returns (I've hit this problem myself).

如果你点击url栏然后单击取消或按下手机上的关闭按钮,然后返回到safari,功能将启动,一切都将开始工作。不是一个可接受的解决方法。

If you tap the url bar then click cancel or push the off button on the phone and go back to safari the functions will kick in and everything will start working. Not really an acceptable workaround.

这篇关于触发电子邮件叠加后iPhone jQuery中断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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