Reading time: < 1 minute
Hello, today we will learn how to detect when a web page has been opened using JavaScript, for example, to refresh its content.

To detect when the web page has been opened, we use the following function:
$(window).focus(function () { console.log("focus web opened"); });
To detect when it is closed, we use this function:
$(window).blur(function () { console.log("blur web closed"); });
