Skip to Content
0
Former Member
Jun 16, 2006 at 09:41 AM

Capturing browser close event

104 Views

Hello everyone,

Even though this question has been answered before, I find that none of the answers seem to work for me.

My problem is the following: Locks are placed on records and tables at certain points in my application. But if the user simply closes the browser without closing the application properly, all the locks are still in place. So I need to catch an event that allows me to ABAP my way out of this.

I have the following BSP page which loads my application:

function startBSPApplication()

function endBSPApplication()

<frameset id="<%=guid %>_FRAMESET" rows="*,0" onload="startBSPApplication('<%=guid %>_A');" onunload="exitBSPApplication();" noresize framespacing="0" frameborder="0" border="0">

session_default_frame.htm">

<noframes>This browser does not support frames.</noframes>

</frameset>

The start and end functions simply start and end a session, and I find myself unable to actually call an ABAP function in there. All ABAP code placed inside the javascript functions is called everytime the page is loaded, not everytime the function is called and that's not what I want.

I also already tried the <bsp:htmlbEvent> tag, but I couldn't get that to work either. I tried it like this:

Notice however that I wrote this on top of the frameset. Does this mean that the onunload event will be called twice and does this cause a problem?

I tried to call the onDestroy event from within my endBSP function, but nothing happened either.

<htmlb:content design="design2003" >

<htmlb:page title="Capture browser close " >

<htmlb:form>

<bsp:htmlbEvent id = "myid"

onClick = "onDestroy"

name = "onDestroy"/>

<script for="window" event="onunload" type="text/javascript">

alert('Starting the Server Event');

onDestroy();

</script>

</htmlb:form>

</htmlb:page>

</htmlb:content>

Does anybody have another suggestion, or notice me overlooking something?

Thank you in advance,

Niels.