I would like to refresh a page after it gets back into focus. For the refreshing part I thought I might just use:
location.reload();
The tricky part is how do I determine when to refresh?
First the window has to loose the focus (which could be determined through .blur()
I assume).
Only after the window which lost focus gets back into focus should trigger the refresh of itself. Can I use .focus()
on location? Or do I have to use something else here?
How can I combine these two cases?
$(window).on('focus', ...)
– SheedywinFocus = 0
;, then use conditional statements. if(winFocus == '0'){ winFocus = '1'} if(winFocus == '1'){ winFocus = 2}if(winFocus == '2'){ location.reload(); } Just re-write the code to work for you, and use it in your focus & blur calls. – Bloomsbury