1 Reply Latest reply on Jul 16, 2007 9:01 AM by JKohn99

    Block Refresh on my mxml page

    rajeeva_nagaraj Level 1
      How can i block F5 refresh on my mxml page
        • 1. Re: Block Refresh on my mxml page
          JKohn99 Level 1
          You can't entirely block the refresh since it is a function of the Browser. However you can add some JavaScript so the user is given a yes/no prompt.
          Add the following java script method to the page wrapping your flex swf.

          window.onbeforeunload = function()
          return "some are you sure message";

          If you want this in all your flex apps add the java script to the index.template.html
          (Assuming you're using Flex Builder for development)

          If you want to get fancier and call methods on your flex app to get some state
          do the following:

          - In your flex app add call backs for methods you want to call
          in your java script get a handle to the swf
          (If you use the index.template.html you can do:
          var flex = document.${application} || window.${application};

          Now you can call methods your swf (ones where you've registered call backs)

          One kicker however:
          You can't take actions in Flex based on the users selection as you can't get access to the results of the ok/cancel dialog.