Pete Wilson
Pete Wilson

Reputation: 8694

JavaScript: check for window exists && is/is not minimized

I want to be sure that any popup opened earlier not only exists, but is not minimized. An earlier discussion talked about checking for the window's existence. I'm guessing (hoping!) that giving focus to an already-open window will restore that window if it's been minimized.

Is that the case, or no?

Thanks!

Upvotes: 1

Views: 1607

Answers (1)

TERMtm
TERMtm

Reputation: 1933

You can do both, assuming 'window' is your reference to the tab or browser window you and detect focus and set it using these:

function detectFocus(state){
   return "Window is now "+state;
}
window.onfocus = function("in focus")
window.onblur = function("not in focus")
/*You then can set state with this method of window:*/
if(needToRestore==true){window.focus}

Upvotes: 2

Related Questions