Confirmation of browser close event

Hello,
In my application, I have a function "myCloseFunction" which looks something like this:
public function myCloseFunction
     Alert.show("This is an alert.");
     trace("myCloseFunction called");
This is only called upon closing the browser (set up using ExternalInterface.addCallback and window.onbeforeunload)
The strange thing is, no alert ever pops up BUT the trace does show.  I have (of course) imported the alerts library (and used alerts elsewhere successfully in the application).  Has anyone ever experienced it or does anyone know of a fix?
I will post my Javascript and .mxml file if needed, though I doubt it is.
Thanks in advance for your help!

hi,
Frastructed with the window close example using ExternalInterface.addCallback provided by Adove not working. Any help would truly appreciated.  here is what i've found:
1. when tested, it passes data from html to Flex if I use onchange="callApp();" of the <Input> tag by typing something to invoke onchange event;
2. if I choose to use window.onbeforeunload = callApp(); at the JavaScript section to detect window closing event, it does detect window is closing, but it won't pass the data ("Window Closing") to Flex. 
Thank you very much for any help.
In Html:
<html><head>
<title>wrapper/AddCallbackWrapper.html</title>
<SCRIPT LANGUAGE="html/JavaScript">
   function callApp() {       
        window.document.title = document.getElementById("newTitle").value;       
        mySwf.myFlexFunction("Window Closing");
    //window.onbeforeunload = callApp();   
</SCRIPT>
</head>
<body scroll='no'>
<h1>AddCallback Wrapper</h1>
Enter a new title: <input type="text" size="30" id="newTitle" onchange="callApp();">
<table width='100%' height='100%' cellspacing='0' cellpadding='0'>
    <tr>
        <td valign='top'>
            <object id='mySwf' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab' height='200' width='400'>
                <param name='src' value='testWrapper.swf'/>
                <param name='flashVars' value=''/>
                <embed name='mySwf' src='testWrapper.swf' pluginspage='http://www.adobe.com/go/getflashplayer' height='100%' width='100%' flashVars=''/>
            </object>
        </td>
    </tr>
</table></body></html>
In Flex:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initApp()">
      <mx:Script>
          <![CDATA[              
          import flash.external.*;
          import mx.rpc.events.ResultEvent;
          import flash.events.Event;
          import mx.rpc.events.FaultEvent;    
          import mx.controls.Alert;
     public function initApp():void {
        ExternalInterface.addCallback("myFlexFunction",myFunc);      
     public function myFunc(s:String):void {           
        Alert.show(s);    
    ]]> 
  </mx:Script>
  <mx:Label id="l1"/> 
</mx:Application>

Similar Messages

  • Catching browser close event and showing my own popup

    Hi,
    I want to show my own warning popup on browser close event. Kindly help me with the solution.
    Thanks a lot in advance.
    Lavanya.

    Lavanya,
    I don't think you could show a ADF Popup during the onload event. Instead, you could use javascript's confirm method to prompt the user to choose what they want to do and perform that operation accordingly.
    Ex :
    jspx code
       <af:document id="d1" onunload="performUnloadEvent" clientComponent="true">
                <af:resource type="javascript">
                  // For Mozilla and Firefox
                  if(window.addEventListener){
                  window.addEventListener('beforeunload', function (event) {
                    showConfirm();
                  // For IE
                  else if(window.attachEvent){
                       window.attachEvent('onbeforeunload', function (event) {
                    showConfirm();
                  function showConfirm(){
                          var eventSource = AdfPage.PAGE.findComponentByAbsoluteId('d1');
                          var sel = confirm("Are you sure you want to exit?");
                        if(sel==true){
                            alert('Perform OK Operation');
                            var x = AdfCustomEvent.queue(eventSource, "handleOnUnload", {result : 'ok'},false);
                            var y = 0;
                        else {
                        alert('Perform Cancel Operation');
                         var x = AdfCustomEvent.queue(eventSource, "handleOnUnload", {result : 'cancel'},false);
                         var y = 0;
                </af:resource>
                <af:serverListener type="handleOnUnload" method="#{UnloadHandler.onUnloadHandler}"/>
                <af:form id="f1" clientComponent="true">
                </af:form>
            </af:document>onUnloadHandler method in bean
        public void onUnloadHandler(ClientEvent clientEvent) {
            System.out.println("Unload Event fired..");
            String outcome = clientEvent.getParameters().get("result").toString();
            if(outcome.equalsIgnoreCase("ok")){
                System.out.println("Outcome is OK ");
                // Perform some operation like Commit;
            else if(outcome.equalsIgnoreCase("cancel")){
                System.out.println("Outcome is Cancel ");
                // Perform some cleanup operation like Rollback;
        }-Arun

  • Call Webservice/API during browser close event

    Hello,
    I am using JDEV 11g. My application catches the browser close event to call a return Task Flow.
    I am wondering if its possible to call a webservice/API during the same event.
    Thanks
    Padmapriya

    Probababy too late to ask .. did u manage to get this resolved.
    I am not able to call any server Listeners during browser close event ...
    Details here -Re: Calling an ActionListener on browser window close using JS event queuing

  • Browser Close Event

    Hi,
    I want to track Browser close event in EP to close all the sessions of the user.
    Plz guide me with detailed steps.
    Thanks in advance.
    Regards,
    Priya

    Hi search for "Browser close event" in google.
    Result: there is no such thing. You can do something with onbeforeunload but that might not work for all browser.
    Kai

  • How to catch browser close event excluding navigation events

    Hi,
    I tried using onBeforeUnload event and onUnload events.. but they are catching navigation events within the same site. Could you please let me know how I can catch browser close events without catching Navigation events?
    Thanks.

    Just set them to null when navigation takes place.
    Said that, you should be asking Javascript/DHTML related questions in a forum devoted to Javascript/DHTML. There are ones at webdeveloper.com and dynamicdrive.com. This has nothing to do with Java.

  • How to detect browser close event in flex ?

    How to detect browser close event in flex ?

    This link may help:
    http://cookbooks.adobe.com/post_Close_event_of_browser_or_browser_tab-18211.html
    Best,

  • Capturing browser close event

    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">
        <frame name="<%=guid %>_A" src="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.

    Hi Eddy,
    I can't find anything really helpful in that blog. Except maybe adding the onbeforeunload attribute to my frameset and calling a JS function to back it up.
    The problem still persists that any ABAP you put in a JS function is executed regardless of wether or not the function is actually called.
    I need to get to my DO_HANDLE_EVENT somehow when the user closes the window.

  • Can Flex detect browser close event?

    Is Flex notified by the browser when the browser is closed
    (or browser tab)? I need to be able to save any unsaved data in the
    application before the browser closes.
    Thanks in advance

    Thanks for your reply.
    I found a good example that I followed and got it working:
    http://flexblog.faratasystems.com/?p=134

  • Catching the browser close event...

    Hello Fellow Portal-Heads,
    There's a nagging issue that I've been pondering (RE EP6 NW04).  In the MSS iViews there is the potential issue of a user viewing an employee and then closing the browser via the 'X' (vs. clicking the logoff link).  This 'X-ing' out of the browser leaves the viewed employee locked which is to be expected.  So... anyone have a good way to catch the 'X-ing' out of the browser and then trigger some code to perform a proper logoff?  I've tried inserting code in the masthead which catches a browser unonload() event... but it was not the smoothest operator.
    Cheers,
    Mike
    Message was edited by: Mike Yang

    Hi Mike,
    I have got a chance to work in a similar issue.The following code traps the 'X' of the browser and logoff the user.
    <script type="text/javascript">
    window.onunload = function unloadEvent()
         if (gIsPreviewMode)
              return;
         else
              if(window.screenLeft < 10004)
                     //this is refresh
              else
                     logoff();
    </script>
    Preview is taken care and the code is working fine. I am posting code so that somebody else can use it,
    Regards
    Message was edited by: Rem Swa
    This is for EP6 SP2

  • Browser close button / unload event

    Hi,
    In Ie8 session is carrying when i close the browser using X button. Is there any way to capture this browser close button or any portal unload event.
    Thanks
    Manu

    There is no clean way to do this. The only way i know of is to have a private global javascript variable true/false (true = show the popup, false = show popup) where the default value is true. On every click of link / form submit where you need the popup to be suppressed , set the value as false. (you can do this using a js library which can attach events to onsubmit, onclick of all links)
    However the behavior you are proposing is really , really annoying (as a user), consider your interface before implementing something like this. Valid usecases are prompting the user to save changes before leaving the page, not you are leaving the website (Thats why i typed something or closed the browser)

  • Portal session not being terminated. browser "unload" event

    This line of code is in the portallauncher.default and eventually causes the problem:
    EPCM.subscribeEvent("urn:com.sapportals.portal:browser", "unload", releaseProducerSessions);
    releaseProducerSessions eventually calls a portal component
    WSRPSessionRelease.. which is causing the problem.
    When we upgraded from EP 6.0 to NW 2004, users started recieving the Netweaver Login Screen when they logged out and logged back in, in the same browser. We think this error occurs because NW 2004 implements Web Services Remote Portal functionality.
    We are using SiteMinder as a third party session management tool.
    What we found was that the Siteminder session was being killed but the Portal session was not. Therefore, when users logged back in they would see the generic Netweaver Login Screen, and they could actually just hit "enter" and continue to the portal.
    A successful logoff, users clicked the logoff button, the DSM terminator was being called, thus killing the portal session, then a form was submitted redirecting the users the the siteminder loggoff page, which logs the users off siteminder.
    When the logoff failed, we found that after the DSM Terminator was called
    and before the page was being redirected, a portal component
    (WSRPSessionRelease) was being called, which in turn, RECREATED the portal session. So the user never actually gets logged off from the portal.
    We found that the WSRPSessionRelease component is set to
    a "browser" "unload" event when the portallauncher.default component is first loaded. This is the same component that is being called when the user clicks the "X" to force close the browser.
    Not everytime is the WSRPSessionRelase component being called before the redirect to the siteminder logg off page. Sometimes this component is called after the redirect, and we find that this is a successful loggoff.
    The component is:
    irj/servlet/prt/portal/prtroot/com.sap.portal.wsrp.coreconsumer.WSRPSessionRelease

    Hello Michael,
    The 'log off' issue is a known issue with Portal since EP 6
    Had faced similar issue and SAP suggests to redirect the 'log off' link to another non-SAP site...like your company intranet site.
    This will help the session to break.
    There are 1-2 SAP Notes on this as well.
    Hope this helps.
    Regards,
    Ritu

  • Detect Safari browser close with the iPad 3

    Detect browser close with the iPad 3
    We have a web site being used on the iPad 3 through Safari.
    Our web site is used in a public setting and multiple users login to use it at different times. We have a questions about user account security.
    When a signed in user clicks the home button on the iPad , which minimize Safari and returns them to the home screen, can the user be signed out of our web site? We don’t want someone else to come and open the Safari browser and have access to the previous user's account information. Is there a client-side event that is triggered that we can handle so we can log the user out of the site?

    Is the iPad shared by everyone at this public setting?
    There is currently no way to handle different users on the iPad (or any iOS device).
    They are designed as single user devices.
    If your company is eligible for an Enterprise account, then you could write an app that could handle clearing user credentials but not in the current "normal" environment.

  • On close event

    how to invalidate managed bean scope sesion at user close/leave her browser. it's need on close event or can be done with simple action

    With Firefox I am often experiencing that PopUps do not close at all on CRM 2007. It probably is a bug in the JavaScript framework. Or you set Firefox to pose as an IE and it is requesting the wrong javascript includes. Maybe you can have a look in the browser which libraries are currently loaded (->Firebug).
    Afaik Firefox is supported for CRM, with numerous exclusions of single components. Mostly all the ActiveX stuff.
    cheers Carsten

  • Browser close

    in the mean while i am running my application .suddenly i am closing the browser
    so my application is terminated
    NEED TO BLOCK/DISABLE THE CLOSE BUTTON

    We wanted to do this for an Oracle Forms application - the browser simply doesn't communication the 'close' request to the application.
    The best you can do is launch the application from a starting HTML page, and in that page put some Javascript to notice the close event and pop up a message saying, effectively, "Oi, don't do that!"
    It does nothing to stop the close, but you can be optimistic and hope it'll discourage the user from doing it again...

  • Record "logout" on Browser close

    Is there a way to record a browser close? We're trying to track user's time inside the application. I've already instituted a trigger to catch the login and record, but unless the user actually uses the logout link in the application, I am stuck. Is there a way to activate a PL/SQL code snippet when the browser is closed? Can I institute this on Page 0?

    You could use some javascript to catch the window.onbeforeunload event, but that is kludge to say the least... I believe there is a plugin for APEX 4.0 that might help here...: http://www.apex-plugin.com/oracle-apex-plugins/dynamic-action-plugin/skillbuilders-save-before-exit_43.html
    They claim it will handle the browser closing as an event.. So you could use this to catch them closing the browser..
    Thank you,
    Tony Miller
    Webster, TX
    I don't know what your problem is, but I bet it's hard to pronounce.
    If this question is answered, please mark the thread as closed and assign points where earned..

Maybe you are looking for

  • Creating A Dynamic Bilingual Form

    I'm a relative newbie just trying to figure out the best way to create a single form which would allow the user to change the language (English/French) on-the-fly. So based on what the user selects as their language (radio button) all of the text cap

  • My old Galaxy SII is outperforming my new iPod Touch 5!?!

    I just got a new iPod Touch 5 Space Gray. I'm testing it against my old Samsung Galaxy SII. My old G SII is outperforming my new iPod 5 in a few areas and it's making me very disappointed. My iPod 5 freezes on online video while my G SII doesn't. My

  • Screen Resolution problem in Solaris 10

    I recently installed Solaris 10 in a DELL GX260 pc. After I've changed from Xorg to Xsun, I was able to go into X-window. However, when I tried to change the resolution in the Java desktop, it shows an error message: The XServer does not support the

  • Problem with jdbc:odbc returning incorrect number of rows.

    Hello, Am sure i have done something stupid, but i have an issue with jdbc:odbc .... It is a simple sceanrio that i have coded umpteen times before ... I have the following .... 1. Connection to DB2 on an IBM i5 (I apologise for not using native driv

  • ERROR MESSAGE WHEN WE ADDING A BUILDING

    hi , We have a WCS : /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Tableau Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-pad