How to close browser window with buttonclick?

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:


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

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

<script language="javascript">
function closewindow (){


Does anyone have a solution?