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

Similar Messages

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

  • 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

  • Catch AE close event

    Hi,
    I'm working on scripts for AE, and I am currently trying to find a way to catch an event when the user close the application (so I can execute some code before it closes).
    I saw some onClose() functions but I heard they don't work anymore with CS6...
    Thank you for your Time!
    Ekibyo

    Hi!
    Actually, you don't need to catch the close event.
    When After Effects closes, it checks this folder:
    Adobe After Effects (your version)/Support Files/Scripts/Shutdown
    and runs the scripts present in this folder.
    So if you paste your script in the Shutdown folder, it'll be launched on close event.
    If you want to launch scripts on Startup, you'll find a Startup folder as well...
    Cheers,
    François

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

  • 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

  • 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

  • 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

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

  • Varification Number Generation and showing it as popup

    I want to show a popup of varification number when user inserts a form.
    let say there are 3 fields in a form, first two are visible and can have any info. third one is hidden and it generates auto numbers, first i need that it must generate some random numbers upon each submission of form. Second i want this randam generated number to be shown to the user as popup and tells user that it is his/her verification number. and in future if he/she wants to check what they entered, they will be able to fetch with that verification number.
    Any help will be appriciated
    Thanks in Advance
    Mazahir Abbas

    If its hidden you don't need to prefetch it as users don't get to see it. You can assign it from the Submit PLSQL process itself and set that hidden item(say P100_VERIFICATION_NUMBER) with the value.
    Then add an onload Javascript that displays the message when the hidden item not null(so that it runs only after submit process)
    alert(' Your Verification Number is :'+ $v('P100_VERIFICATION_NUMBER') );You can also do that directly from the PLSQL process
    BEGIN
      --process
      :P100_VERIFICATION_NUMBER := <new verification number>;
      htp.p('<script>');
      htp.p('alert("Your Verification Number is :'||:P100_VERIFICATION_NUMBER||'")');
      htp.p('</script>');
    END;Random numbers needn't be unique and might not be good idea in the long run. You should be using sequences in these situations. However if you want it to generate random values you can use
    FLOOR(DBMS_RANDOM.value(0,1)*99999999999999999999) generating a 20 digit random no.

  • How to catch error message and show it in VC?

    I want to catch the error message and show it in VC.For example, if there is no data row in table view queryed from data service, then popup a window to show the message "No Data Found".I don't konw how to implement it!

    Hello Kane
    use expression{disble this after defining erroe messege} box in that popup there u can define your own message as error or warning accordingnly it display message
    I hope it work or Let me know it
    Regards
    ````Satish````

  • Every time I try to "export" iPhoto closes completely and an error shows up

    Every time I try to "export", iPhoto closes completely and shows an error.

    That's where it is...
    /Library/Application Support/iPhoto/*/HPPhotoExport
    Remember you have two Libraries:
    HD/Library and
    HD/Users/Your Name/ Library
    On 10.7: Hold the option (or alt) key while clicking on the Go menu in Finder to access the User Library
    It may be in either.
    Regards
    TD

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

Maybe you are looking for

  • Error while sending SMS

    Hi , I have done the setup for SMPP Driver properties. We have a clickatell account and registered the server IP with them. I am getting the following error while running the BPEL process to send SMS. Please help. Error while sending notification to

  • Just got replacement ipad mini, got told it would be backed up on iCloud, not working?

    I have just got a replacement ipad mini and at the apple store I got told to wait 1 hour for the iCloud backup to work which I have and I've gone to turn on the new replacement and back it upto my iCloud but it's telling me there is no backup availab

  • Importing problem with coolpix s610

    does anyone know why i cant import using some digital camers? i have a nikon coolpix s610, and sony cybershot dsc-t30

  • I do not have a photo button option

    I do not have the option to sync or upload photos to itunes because I do not have the button as an option. This is a new computer and a new ipad. I was able to get it to work once and upload pictures to my ipad from my old laptop but now its not even

  • Xcelsius Error - IPOINT (Integration Option for MS Sharepoint) & BO Edge

    Am getting below error while trying to launch Xcelsius file from the 'Content Explorer'. It opens up with the URL 'http://<SERVERNAME>/_layouts/Xcelsius/flash/view.aspx?cafWebSesInit=true&appKind=InfoView&service=/InfoViewApp/common/appService.aspx&l