JavaScript setTimeout does not fire after Window.Open

I have an ASP.Net webpage that currently works on iOS4 but not on iOS5.

On the parent webpage, I have a button that opens a child window. And I update setTimeout in the parent window right after the open window is called.

I noticed on iPhone iOS5 that when it opens a child window, the setTimeout function on the parent page is not called until I return to the parent window and then back to the child window to see the update.

Here is a snippet of my code on the parent page and where I think the problem is

WindowManager.OpenWindow('...') t = setTimeout(function() { handles[0].testfx(); }, 1000); 

this works on iOS4 but not on iOS5.

Any ideas?

+6
source share
2 answers

iOS5 does pause JavaScript when the window is not an active window. There is nothing you can do about it, so it’s best to try changing your setting so that JavaScript does not start when your window is in the background.

You said you were doing setTimeout refresh thing in the parent window . Why are you doing this? Honestly, this sounds a little strange - why do you want to update something when the user cannot even see your page? What exactly does the line handles[0].testfx(); for you?

+3
source

This is just a suggestion, since I do not have access to test this, but you can hack it using window.postMessage . An example of this can be found here .

In your case, you probably want to check if the required amount of time has passed, and if not, call window.postMessage again, otherwise call the handler.

I'm not sure how quickly window.postMessage calls will be processed, if at all, if not in the active window.

+2
source

Source: https://habr.com/ru/post/919155/


All Articles