简体   繁体   English

如何关闭window.open

[英]How to close a window.open

I know that you can close a window.open with window.close but is there another way. 我知道您可以使用window.close关闭window.open,但是还有另一种方法。 I have a popup that opens facebook connect and i want to shut the popup whenever the user connects to facebook and then refresh the parent window...I thought in the past i used 我有一个打开Facebook Connect的弹出窗口,我想在用户连接到Facebook时关闭弹出窗口,然后刷新父窗口...我以为我过去使用过

TARGET = "_top"

here is my code 这是我的代码

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

Also

$('#signin_menu a').attr("href")

is equal to 等于

"https://graph.facebook.com/oauth/authorize?client_id=145554402127660&display=popup&redirect_uri=http://pgp.dev/fb_receive&scope=publish_stream,rsvp_event,offline_access,email,user_about_me,user_activities,user_birthday,user_events,user_groups,user_interests,user_likes,user_location,user_notes,user_online_presence,user_photo_video_tags,user_status,user_website,read_friendlists"

So How do i close this popup 那么我如何关闭这个弹出窗口

You can use close() method of created popup that is returned by the open() method as object: 您可以使用open()方法作为对象返回的已创建弹出窗口的close()方法:

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();

您可以使用以下内容

window.close();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM