iPhone的Javascript执行时间执行时间、iPhone、Javascript

2023-09-11 01:14:52 作者:庆幸是你.

在苹果的文档它说,

JavaScript执行时间限定为10秒为每个顶级入口点。   如果超过10秒,你的脚本执行,iPhone上的Safari OS停止在随机位置执行脚本

JavaScript execution time is limited to 10 seconds for each top-level entry point. If your script executes for more than 10 seconds, Safari on iPhone OS stops executing the script at a random place

我打算有一些JavaScript每10秒左右,将做一个AJAX查询服务器和重写所需的页面的只是部分。这会不会有可能与设备上的这些限制呢?

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. Will this be possible with these restrictions on the device?

推荐答案

是的,这是可能的,前提是你使用时调用每10秒,而不是忙等待10秒的回调实现它。换句话说,如果你使用的setInterval来实现这一点,那么你的罚款。

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. In other words, if you use setInterval to achieve this, then you're fine.

 
精彩推荐
图片推荐