1

After login I have function which gets control.

function formLoginSubmit() {
    if (typeof window.formLoginSubmit_custom != 'undefined') {
        window.formLoginSubmit_custom();
    }
    location.href = '/';
}

And in function formLoginSubmit_custom() I have to do some operations with opening Iframes. The problem is that:

  1. I can't modify formLoginSubmit (don't ask it's just a task I have to do)
  2. Before I've done all operations with my iframes document starts redirecting because of this: location.href = '/';

So how can I stop executing code asyncronously And let my formLoginSubmit_custom() function finish all the operations before changing location.href

What are my options?

Andrea Parodi
  • 5,534
  • 27
  • 46
user2950593
  • 9,233
  • 15
  • 67
  • 131
  • If you can't modify `formLoginSubmit_custom` and it is performing async operation, you are in trouble... The only thing you can do is schedule the location change with setTimeout and hope formLoginSubmit_custom has complete. Otherwise, change `formLoginSubmit_custom` to accept a callback and to call it when async operation complete. In the callback body, you'll change the location – Andrea Parodi Feb 01 '14 at 14:30
  • This article may help you [enter link description here][1] [1]: http://stackoverflow.com/questions/1859185/how-to-force-sequential-javascript-execution – Hussam Hussien Feb 01 '14 at 14:34

1 Answers1

0

Not possible. You would need to change formLoginSubmit to achieve that.

You could drop a cookie "do some work", and when page is reloaded, if you can execute some code - if you find a "do some work" cookie - you could execute that custom() logic in there. But that might not be useful for you depending on what you're trying to achieve.

Karolis
  • 2,899
  • 2
  • 23
  • 38