Browser window close check in Action Script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • apurvaG
    New Member
    • Apr 2007
    • 14

    Browser window close check in Action Script

    Hi All,

    I wanted to know, can I check in action script whether the browser window which loads my swf file has been closed? Basically I wanted to call a action script function which will be triggered when the browser window is closed. Can I do this check in action script of the flash file which is loaded in the browser?


    Thanks in advance,
    Apurva G
  • bnashenas1984
    Contributor
    • Sep 2007
    • 257

    #2
    Hi
    This is not the exact answer to your question but it might help.

    As you might know many people are having problems because of difference between internet browsers like IE and FireFox. I don't think what you need is possible . I'v been looking for the same thing for months and found nothing.

    But what you can do is to check with JAVA script on the same page that you have your SWF file .

    Here is the HTML code to do this.

    Code:
    <html>
    <head>
    <title>Detecting browser close in IE</title>
    <script type="text/javascript">
    var myclose = false;
    function ConfirmClose()
    {
    if (event.clientY < 0)
    {
    event.returnValue = 'Any message you want';
    setTimeout('myclose=false',100);
    myclose=true;
    }
    }
    </script>
    </head>
    <body onbeforeunload="ConfirmClose()">
    Close browser!
    </body>
    </html>
    But as I said because of differences between browsers this code only works on IE. You might be able to make another code which works on other browsers to


    Good luck

    Comment

    Working...