I am doing an application which is using Flex UI and java . I calling the swf as an object embeded in jsp. I want to do a functionality call will I do a browser close.This functionality was already I have implemented in a button call. So I want to make the javascript to poin to the flex function which is doing this. I have implementd as below,

This call to flex functon is working fine for me...The issue is due to the return statment I am getting an confirm alert asking are you sure to navigate away from thiis page..... The functionality I am doing is cancel transaction function . If the user click OK then every thing is fine. But if he clicks cancel the browser will not get closed but and transaction will also get cancelled which is wrong.If i remove the return then functionality will not get called as the browser is getting closed before it calls the function.I tried setimeout also ..but it is not possible to call setTimeout in onbeforeunload Could somebody help me to fix this either through Javascript or flex

Paul_Wilkins
—
2012-03-19T23:14:40Z —
#2

jodha said:

If i remove the return then functionality will not get called as the browser is getting closed before it calls the function.

Have you tried seeing how things go in the onunload event?

jodha
—
2012-03-20T06:54:35Z —
#3

Yes paul ... I tried as below,

window.onunload = function() { getMyApp("mySwf").cancelFunction();

alert("hi");
}

But alert itself didn't come . if I gave only alert , that is coming. If I do a functionality call alert also not coming

Paul_Wilkins
—
2012-03-20T09:31:42Z —
#4

jodha said:

But alert itself didn't come . if I gave only alert , that is coming. If I do a functionality call alert also not coming

It seems that cancelfunction is asynchronous, so you will need to do something to give it time to act.That could be as simple as checking if you need to cancel anything, and if so, follow the cancelfunction with an alert saying "Transaction cancelled".