如何关闭弹出窗口并重定向父窗口 [英] How to close popup window and redirect the parent window
本文介绍了如何关闭弹出窗口并重定向父窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
string dialog_url = "http://www.facebook.com/dialog/oauth?client_id=" + app_id + "&redirect_uri=" + Server.UrlEncode(my_url) + "&scope=" + permission;
ClientScript.RegisterClientScriptBlock(typeof(Page), "key", "window.open('"+dialog_url+"','_parent','');");
我将此代码用于弹出权限对话框.当用户单击允许Facebook将用户重定向到弹出窗口中的我的应用程序时.我需要将代码从弹出窗口发送到父窗口,然后在用户单击允许时关闭弹出窗口.
I use this code for popup permission dialog. When user click allow facebook redirect user to my app in the popup. I need to send code from popup window to parent window then close popup when user click allow.
推荐答案
如果这是您要寻找的,请告诉我... 父窗口:
Tell me if this is what you are looking for... Parent Window:
<html>
<head>
<script language="Javascript">
function showFBWindow(){
url = "allowfbchild.html"
newwindow=window.open(url,'name','height=200,width=150');
if (window.focus) {newwindow.focus()}
}
</script>
</head>
<body>
<input type="button" OnClick="showFBWindow()" value="Open FB" />
</body>
</html>
子窗口(allowfbchild.html):
Child Window(allowfbchild.html) :
<html>
<head>
<script language="Javascript">
function redirectToFB(){
window.opener.location.href="http://wwww.facebook.com";
self.close();
}
</script>
</head>
<body>
Allow the user to view FB
<br/>Are you sure?
<input type="button" value="Ok" OnClick="redirectToFB()" />
</body>
</html>
这篇关于如何关闭弹出窗口并重定向父窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文