Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 2 Jahren, 3 Monaten
Letzter Beitrag:
vor 2 Jahren, 3 Monaten
Beteiligte Autoren:
MichaelRug, Danny Lauwers

[WB20] How to trap when a user closes or leaves a page

Startbeitrag von MichaelRug am 24.03.2016 00:44

Hello All:
I'm using WebDev 20, and I need to do a small processing before the user closes or leaves the current page. I tried putting that process in the Closing of PAGE_Test event, but it seems this is not always triggered... I think if user clicks on a button that opens another page, then this event doesn't happen (I'm not sure if this is exactly the case, but for sure this event not always happens...).

Is there any other way to accomplish this task?

Thanks in advance for your help.

Michael R.


Hi Michael,

You have to implement the onbeforeunload event.

In your PAGE or PAGE Template you have to link the event

LOAD (onload) of PAGE_Test (BROWSER)

// Set BeforeUnLoad event

The B_BeforeUnloadPage is also a browser function of that page/Template that will handle the event. I have implemented this on my Template, so all pages based on this template have this functionality.

PROCEDURE B_BeforeUnloadPage(pclEventJS is object dynamic)

// if a modification was made
IF AJAXExecute(IsPageModified) THEN
sMessage is string = "Opgelet, uw aanpassingen zullen verloren gaan wanneer u de pagina verlaat zonder de gegevens op te slaan !"
pclEventJS:returnValue = sMessage
RESULT sMessage

Ofcourse you have to handle the code in this last routine.

In my case, if you try to close or browse away from the page when the page was modified (user changed something but did not save) the IsPageModified flag is true and the message will be displayed.
[attachment 1897 screen1.png]

Depending on your selection, you stay on the samepage or you continue to close or goto the other page.

Good luck !

von Danny Lauwers - am 24.03.2016 08:37
Hello Danny:

Thanks for the help. I will give it a try and see how it goes.

Many thanks again.

von MichaelRug - am 25.03.2016 19:28
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.