How to close a window.open

后端 未结 2 1900
一个人的身影
一个人的身影 2021-01-26 16:42

I know that you can close a window.open with window.close but is there another way. I have a popup that opens facebook connect and i want to shut the popup whenever the user con

2条回答
  •  误落风尘
    2021-01-26 17:13

    You can use close() method of created popup that is returned by the open() method as object:

    var myPopup;
    
    $(document).ready(function(){
        $('#signin_menu a').click(function (){
    
            myPopup = window.open(
                $('#signin_menu a').attr("href"),
                'mywindow',
                'width=850,height=400');
    
            return false;
        });
    })
    

    To close do the following:

    myPopup.close();
    

提交回复
热议问题