Preserving onfocus

Author: jts04Created Feb 22, 2017Updated Jan 14, 2026
Labelsbug

I'm currently using Sweetalert with Phaser, game engine.

Phaser works only when it gets focus of window. So there is a problem since Sweetalert change window.onfocus and doesn't restore that.

I guess the solution is simple :

  1. store its previous window.onfocus in constructor
  2. restore window.onfocus to previous version in 'sweetAlert.close' function