# How to close browser window with buttonclick?

**URL:** <https://forum.kirupa.com/t/how-to-close-browser-window-with-buttonclick/293062>\
**Category:** flash\
**Created:** [July 22, 2009, 5:41pm UTC](https://forum.kirupa.com/t/how-to-close-browser-window-with-buttonclick/293062 "2009-07-22T17:41:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nando973](https://avatars.discourse-cdn.com/v4/letter/n/51bf81/32.png) [@nando973](https://forum.kirupa.com/u/nando973)\
**Post date:** [July 22, 2009, 5:41pm UTC](https://forum.kirupa.com/t/how-to-close-browser-window-with-buttonclick/293062/1 "2009-07-22T17:41:38Z")

</div>

Hi,  
I spent hours and hours trying to figure out how to close the browser window from within the movie (on button click) - I have read thousands of posts and tried different methods, but nothing worked.

Here is the latest one that I was trying:

code for the button:

```auto
close_btn.addEventListener(MouseEvent.CLICK,onCloseBtn);

function onCloseBtn(myevent:MouseEvent):void{    
    var myurl:String="javascript:self.close()";
    var mywindow:String="self";
    ExternalInterface.call("closewindow",myurl,mywindow);
}

```

And I put this javascript code in the head of the html page

```auto
<script language="javascript">
function closewindow (){
    self.close();
    }

</script>

```

Does anyone have a solution?
