How can the popup appear when the use is trying to move to another tab or window

How can the popup appear when the use is trying to move to another tab or window