JavaScript Tutorial - 'unload' event | Detect when the browser window has closed

preview_player
Показать описание
By using the "unload" event in JavaScript you are able to detect when the window has closed. In the case of an iframe, it is possible to detect when the src attribute has been removed or changed.

In this video we take a look at an example of the "unload" event in the case of an iframe, where we send a message to the parent window when the child window (within the iframe) gets un-loaded.

Support me on Patreon:

For your reference, check this out:

Follow me on Twitter @dcode!

If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!
Рекомендации по теме
Комментарии
Автор

WOAH guys! stop HATING him! his new videos are really helpful and good quality watch them and come and then comment..

envplayz
Автор

5:13 for example when you make login or register on popup page and when exit it js will react and check if session started

patakxd
Автор

Interesting video, thanks! could this be adapted to trigger a php logout script if a user closes the window rather than using the logout button?

photoinshot
Автор

I enjoy your videos, but your video audio is usually low, making it difficult to listen

desmondezo
Автор

Good evening everyone.🖤


I'm facing the case and kindly hoping if there is any one could gimme a small hint.

The case is to log out automatically from the app and kill the session when the user close the browser or the tap.

My first idea was when the user close the browser or the tap the ajax will call the end point to end the session.

But I have been looking for the solution for 3 days ago, and no event could even appear alert when the user do what I told you about before.

I just found some events that work with (old browsers versions).

So is there anyone has an ide to solve such a problem?

I appreciate your help, thanks in advance.

liongh
Автор

na aavdtu hoy to na bnav video... time waste

mayurvadher
Автор

change your keyboard if you are gonna put videos on yt

jackfrost