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

Similar Messages

  • 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,

  • 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 window close event and do some task before exiting

    Hi 
    Anyone knows how to detect window close event and do some task before exiting ?
    Sridhar
    Solved!
    Go to Solution.
    Attachments:
    window close event.JPG ‏34 KB

    Yes .You can discard the panel close event by passing "TRUE" boolean value to the "discard ?" terminal which is lied in the right side of that panel close(filter) event.& It will work in executables.  See attached picture.
    Attachments:
    Panel Close.JPG ‏12 KB

  • 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

  • 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

  • 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>

  • Trouble detecting browser close in Internet Explorer

    Please help!
    I'm trying to detect when the browser closes (or tab closes, or page reloads, etc.) so that I can save user information. I've followed the advice of others on the web, and have it working with Firefox, but not IE. The code in my wrapper is below, which attempts to get access to the embedded swf object a variety of ways to presumably handle multiple browsers. PLEASE HELP!
    //  Function to get a reference to the embedded swf file
                        function getFlashMovieObject(movieName)
                          if (window.document[movieName])
                              return window.document[movieName];
                          if (navigator.appName.indexOf("Microsoft Internet") == -1)
                            if (document.embeds && document.embeds[movieName])
                              return document.embeds[movieName];
                          else // if (navigator.appName.indexOf("Microsoft Internet") != -1)
                            return document.getElementById(movieName);
    Here's the code that calls this function:
                        window.onbeforeunload = function() 
                            var myApp = getFlashMovieObject("MySwf");
                            return myApp.onCloseApplication();
    Here's the code that embeds the swf:
                      var flashVars = {};
                      var strHref = window.location.href;
                      if ( strHref.indexOf("?") > -1 )
                            var strQueryString = strHref.substr(strHref.indexOf("?")+1);
                            var aQueryString = strQueryString.split("&");
                            for ( var iParam = 0; iParam < aQueryString.length; iParam++ )
                                var aParam = aQueryString[iParam].split("=");
                                flashVars[aParam[0]] = aParam[1];
                    var params = {};
                    params.quality = "high";
                    params.bgcolor = "#ffffff";
                    params.allowscriptaccess = "sameDomain";
                    var attributes = {};
                    attributes.id = "MySwf";
                    attributes.name = "MySwf";
                    attributes.align = "middle";
                      //create your instance of your SWF
                      swfobject.embedSWF("MySwf.swf", "flashContent", "100%", "100%", "10.0.0", "expressInstall.swf",
                        flashVars, params,attributes);

    To make the hyperlinks in PDF file work, do the following:
    Open your Adobe Reader
    Then select Edit à Preferences… from the Action Bar.
    To make the links active, select Documents (under Categories).  On the right side, now under PDF/A View Mode, using the drop-down change  “Only for PDF/A documents”  to  “Never”.   Now click the OK button.

  • 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.

  • 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

  • Detecting browser close

    I would like to detect when the user closes the browser and
    either 1) get the flash movie to save whatever data is unsaved or
    2) determine from the flash movie if there is unsaved data and get
    the browser to pop-up a message.
    Does anyone have any ideas on this? Or can point me to any
    resources?
    Thanks
    Scott

    A close of the browser instance won't terminate the session. The session will simply timeout. The default timeout is 30 minutes, otherwise you can specify it in the web.xml.
    If you want to terminate the session immediately on close of the browser instance, consider using the onunload event of the body in combination with some Javascript call to the server side. Keep two things in mind: 1) this doesn't work in older browsers and not at all in current Opera version (because the onunload event isn't been specified in the W3 HTML specification) and 2) this will lead to problems if you have opened the same site in multiple windows and/or tabs inside the same session, you can't keep track of them all. I wouldn't use the onunload event. Just let the session timeout.

  • Detect browser close

    is java servlet able to detect when a user close an IE or NETSCAPE browser!!??

    unfortunately, there is no reliable way unless the browser is IE or Netscape 6.0 or better....versions of NS prior to 6.0 did not support onclose() properly.
    If in your case it IS IE and NS 6.0 or better, then you can use javascript onclose() and do whatever in that method.

  • How can I detect Form Open event and Import data event ?

    We are using Adobe Designer 7 and Adobe Reader 7.0.5. When we open a Form, Initialize event is being called. Similarly when we Import any data, initialize event is being called. At the Initialize event, I want to know whether it is caused by Opening the Form (or) Importing the data. Please respond as we were completely stuck up with this issue.

    My screenshot was only an example how you can approach the issue. I wasnt saying that you should try it with AI....
    Just take a closer look into the DAQmx Events and you will discover something like this:
    hope this helps,
    NorbertMessage Edited by Norbert B on 10-05-2007 02:35 AM
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.
    Attachments:
    DAQmxEvent.PNG ‏11 KB

  • 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.

Maybe you are looking for