Flash + Calling Javascript Function

I have a javascript function on the page to give a pop up warning if the user tries to close the browswer or leave the page, i am trying to allow the page to redirect when the flash movie has finished.  when i try calling a function on the page from Flash, the close page warning still comes up 1st.  Below is the code i am using.

<SCRIPT language=javascript>
            
isRedirecting = true;
            
function setRedirectBrowser() {
alert("TEST")
isRedirecting=false;
}
                  
function closeIt() {
alert(isRedirecting);
if (isRedirecting) {
return 'Please save first';
}
}
</SCRIPT>

I have an test alert in setRedirectBrowser so i can see when the function is called, and it is after the closeIt function runs, is there anyway to redirect the browser without the warning popup coming up.

I am using GetURL("Javascript:setRedirectBrowser ()"); in the Flash movie

dkilbyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

negatyveCommented:
With this code:

            <script language="javascript">
            <!--
                  isRedirecting = true;
                  function setRedirectBrowser()
                  {
                        isRedirecting=false;
                  }
                  function closeIt()
                  {
                        if (isRedirecting) {
                              alert('Please save first');
                              return false;
                        }
                  }
            //-->
            </script>

it works fine for me. Where have you setted the closeIt call? ie:

<body onunload="closeIt()">

?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dkilbyAuthor Commented:
yes i have

<body onunload="closeIt()">
negatyveCommented:
Is my script working? Have you tested it?
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

dkilbyAuthor Commented:
i tested the script and it is not quite what i am looking for, 1st i need to use onbeforeunload not onunload as i am trying to stop the user from closing the browser, if i use the above code the alert box comes up the user clicks OK the browser still closes, i also tried the above code with onbeforeunload when the flash movie finishes the closeIt function runs first then the setRedirectBrowser, i put an alert in the setRedirectBrowser to see at when it runs.

I tried to get the answer in Javascript section, but it seems now the issue is with Flash as it posts back to the page the page tries to reload and the closeIt function fires, instead of the setRedirectBrowser first, below is the link to Javascript question for background.

Thanks for the help

http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_21478805.html
negatyveCommented:
Could you write here the complete html code? (I mean, only the part related to javascript, no content)
dkilbyAuthor Commented:
in Flash at the end of the movie i need it to pass some variables to another page so this is the code i have in Flash

            getURL("javascript:setRedirectBrowser()");
            //getURL("data_transfer.aspx", "_self", "POST");  

I have the passing of variables commented out right now to try and figure out the calling of the javascript function

In the page that holds the flash movie, all i have is the below code

<html>
      <head>
            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
            <title>Test</title>
            
            
          <script language="javascript">
          <!--
               isRedirecting = true;
               function setRedirectBrowser()
               {
                    isRedirecting=false;
                    alert(isRedirecting)
               }
               function closeIt()
               {
                    if (isRedirecting) {
                         alert('Please save first');
                         return false;
                    }
               }
          //-->
          </script>

            
            <style type="text/css">
                  <!--
                  body {
                        margin-left: 0px;
                        margin-top: 0px;
                        margin-right: 0px;
                        margin-bottom: 0px;
                  }
            --></style>
      </head>
      <BODY onbeforeunload="closeIt()">
      <button id="closeWindow" onclick="setRedirectBrowser();">Click Here</button>
            <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="600" height="600" ID="Shockwaveflash1" VIEWASTEXT>
                  <param name="movie" value="<%Response.Write (FileName)%>">
                  <param name="quality" value="high">
                  <embed src="<%Response.Write (FileName)%>" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="600" height="600"></embed>
            </object>
      </body>
</html>
dkilbyAuthor Commented:
ok found something that works.

function closeIT(){
     if (event.clientY < 0)
         event.returnValue = 'Are you sure you want to Quit?'
   }
}

this does what i need, if the user trys closing the browser using the 'X' the warning comes, but at the end of the flash movie the page is able to redirect.

Thanks for the help
dkilbyAuthor Commented:
ok found something that works.

function closeIT(){
     if (event.clientY < 0)
         event.returnValue = 'Are you sure you want to Quit?'
   }
}

this does what i need, if the user trys closing the browser using the 'X' the warning comes, but at the end of the flash movie the page is able to redirect.

Thanks for the help, i will split the points as you both where a lot of help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.