简体   繁体   English

iPhone Javascript执行时间

[英]iPhone Javascript execution time

In the Apple docs it says that 在苹果文档中说

JavaScript execution time is limited to 10 seconds for each top-level entry point. 每个顶级入口点的JavaScript执行时间限制为10秒。 If your script executes for more than 10 seconds, Safari on iPhone OS stops executing the script at a random place 如果脚本执行时间超过10秒,则iPhone OS上的Safari会在随机位置停止执行脚本

I plan to have some Javascript run every 10 seconds or so that will do an AJAX query to the server and rewrite just the section of the page necessary. 我计划每10秒左右运行一些Javascript,以便对服务器进行AJAX查询,并仅重写页面的必要部分。 Will this be possible with these restrictions on the device? 这些限制会在设备上实现吗?

Yes, it is possible, provided that you implement it using a callback that is invoked every 10 seconds, rather than busy waiting for 10 seconds. 是的,如果您使用每10秒调用一次的回调来实现它,而不是忙于等待10秒,则可以实现。 In other words, if you use setInterval to achieve this, then you're fine. 换句话说,如果您使用setInterval实现此目的,那么您就可以了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM