The reason it doesn't work is because you call the functions immediately and assign the return value undefinedto onfocusand onblur.
Instead, onfocusthey onblurmust reference functions by name.
Try the following:
window.onfocus = focuswindow;
window.onblur = hidewindow;
, (). onfocus onblur .