I have been trying to execute some LotusScript code on the event that someone clicks on the X to close a window. Right now I have a OnBeforeUnload event which triggers another window passing it a “/hrjobprof.nsf/removelockonexit?OpenAgent&UID=” as an argument. This method is not consistent. The problem is that is doesn’t work 100% of the time.
Is there any other way to run a LotusScript agent on the event that someone simply closes the window (by the X, or File | close)…
OnBeforeUnload is not universally supported by browsers. In fact, if this is in a Notes form or page (rather than an HTML form you created yourself), I don’t even know how you got OnBeforeUnload - it’s not an event Notes recognizes.
Use onUnload instead. As far as I know, you’ll need to use javascript to call your lotusscript agent.
You’d need to call it by URL, opening it into a separate window. Note that pop-up blockers will prevent this from happening – as they SHOULD.
There is no reliable way to run code from a window close (or when the user navigates to a new URL) on the web. You cannot count on anything happening, so don’t code anything that relies on clean-up code if you can avoid it. If you can’t avoid clean-up code, then you’ll need to record a “start time” somewhere, set a time-out for a complete operation (like removing or disabling the submit button after a certain period has passed), and clean up using a sceduled agent.