iOS Javascript DOM“冻结?”
这里有几个问题:
是否有办法阻止 iOS 在滚动时冻结页面上的 javascript?
当您在另一个选项卡中或切换应用程序时,iOS 是否会冻结 javascript?
iOS 上还有其他主要的 javascript 限制吗?
A few questions here:
Is there anyway to keep iOS from freezing javascript on the page while scrolling?
Does iOS freeze javascript when your in another tab or if you switch apps?
Are there any other major javascript limitations on iOS?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
iOS 6.x 会暂停所有事件计时器以响应滚动等触摸事件,并且在事件完成后倾向于不再启动所有计时器。这是一个众所周知的、超级烦人的 iOS 6 错误。它几乎打破了视差之类的东西。有些人已经诉诸于构建自己的滚动功能。
这是关于同一主题的另一个 StackOverflow:
iOS 6 safari,setInterval 不会被触发
和另一个:
setInterval 在 iphone/ipad(移动 Safari)中滚动期间暂停
这是你能得到的最接近的 bug 报告(Apple 不会公开 bug 报告以维持完美的幻觉,因此开发人员创建了自己的 bug 网站):http://openradar.appspot.com/12756410
这段代码将解冻损坏/丢失的计时器/在页面滚动期间被 iOS 销毁: https://gist.github.com/ronkorving/3755461
这是修复冻结的另一次尝试:iOS 6 js 事件函数如果有 setTimeout 则不会被调用
不幸的是,你无能为力页面滚动时触发事件。就像向上滚动页面时淡出返回顶部链接一样。说到滚动,iOS6就连揉肚子、拍头的力气都没有了。 (iOS5 工作正常,顺便说一句。这是一个回归)
iOS 6.x suspends all event timers in response to touch events like scrolling and has a tendency not to start up all the timers again once the event is done. It's a well known iOS 6 bug that is super-annoying. It pretty much breaks parallax and stuff. Some people have resorted to building their own scroll functionality.
Here's another StackOverflow on the same topic:
iOS 6 safari, setInterval doesn't get fired
and another:
setInterval pauses in iphone/ipad (mobile Safari) during scrolling
and here is the closest thing you'll get to a bug report on it (Apple doesn't make bug reports public to maintain the illusion of perfection, so developers made their own bug site): http://openradar.appspot.com/12756410
This bit of code will unfreeze timers that are broken / lost / destroyed by iOS during a page scroll: https://gist.github.com/ronkorving/3755461
This is another attempt to fix the freeze: iOS 6 js events function not called if has setTimeout in it
Unfortunately, there is nothing you can do to fire events WHILE page scrolling. Like fade out a back-to-top link when scrolling up the page. When it comes to scrolling, iOS6 is incapable of rubbing it's tummy and patting it's head. (iOS5 works fine, btw. This is a regression)
要回答第三个问题,一个相当大的限制是 有时
innerHTML
只是简单的不起作用。从接受的答案来看:To answer the third question, a decent-sized limitation is that sometimes
innerHTML
just plain doesn't work. From the accepted answer: