4 Replies Latest reply on Jan 22, 2008 6:06 AM by robdillon

    Close Browser Window

    Muskieman5000
      Being honest, I'm rather new to ActionScript, but I've created a slide show of movie clips that is contained in a separate browser from the parent sight. At any point during the slide show, I would like the ability to close the browser window by clicking on the movie clip being shown. My attempt at this (with AS) is as follows:

      on (release) {
      getURL ("javascript:window.close()");
      }

      OR

      on (release) {
          getURL("javascript:window.opener=self; window.close()");
      }

      When I test, all I get in OUTPUT are a bunch of errors, and when I import the flash into an actual html file and test, nothing. Would someone please explain what I'm missing? Any help is appreciated.

      Thank you in advance.
        • 1. Re: Close Browser Window
          robdillon Most Valuable Participant
          You can only close a browser window using javascript if that same window was opened using javascript. Some browsers will show an error, some will just do nothing.

          Of course, the user's browser must have javascript enabled and allow popups for any of this to work.
          • 2. Re: Close Browser Window
            Muskieman5000 Level 1
            Thanks for responding Rob. Assuming that both of your points are true, I'm getting errors within Flash when I output:
            _________________________
            **Error** Scene=Scene 1, layer=movie clips, frame=5:Line 2: Syntax error.
                getURL("javascript:window.opener=self; window.close()");

            **Error** Scene=Scene 1, layer=movie clips, frame=5:Line 3: Unexpected '}' encountered
            }

            Total ActionScript Errors: 2 Reported Errors: 2
            _____________________________

            I guess what I'm wondering is am I not able to assign this script to a Movie Clip? And if I am, what am I doing incorrectly?


            • 3. Re: Close Browser Window
              Muskieman5000 Level 1
              Wondering if anyone else may have a reply?

              Thank you for your help!-)
              • 4. Re: Close Browser Window
                robdillon Most Valuable Participant
                While there's a bunch wrong with your javascript, that second error has nothing to do with the line that you quoted.

                As far as I know, window.opener is a read only property that is set when a new window is opened using javascript. You cannot set the value of that property.