我有一个弹出窗口打开使用window.open().我现在想要的是用户能够在这个新窗口中单击2个链接之一:"允许"或"不允许".
当用户单击其中一个链接时,"弹出"窗口应该关闭,并向父窗口返回"允许"或"不允许"或沿着这些行true/ false将要执行的操作.
可能吗?如果是这样,怎么样?
码:
var authWindow = window.open('auth.php', 'authWindow', 'options...');
Run Code Online (Sandbox Code Playgroud)
然后里面只有2个锚点auth.php?
我正在从父母那里打开一个paypal窗口window.open().付款并重定向回我的页面后(在弹出窗口中),我想关闭弹出窗口并更新父窗口URL.
我发现这可以通过window.opener.location工作.
然而控制台显示
window.opener.location为null
重定向后因为子窗口更改,弹出窗口会丢失有关开启器的信息.
好极了 现在有什么办法解决这个问题吗?也许为听父母的网址的父母添加一种"听众"?
I'm interested in how to implement OAuth in React using popup (window.open).
For example I have:
mysite.com — this is where I open the popup. passport.mysite.com/oauth/authorize — popup.主要问题是如何在window.open(popup)和(popup)之间建立连接(window.opener众所周知,由于跨域安全性,window.opener为null,因此我们不能再使用它了)。
?
window.opener每当您导航到其他主机(出于安全原因)时,都将被删除,因此无法解决。如果可能的话,唯一的选择应该是在框架内付款。最上面的文档需要保留在同一主机上。
方案:
可能的解决方案:
那么,2019年推荐的最佳方法是什么?
React包装器-https: //github.com/Ramshackle-Jamathon/react-oauth-popup
我正在尝试将 postmessage 从打开的窗口发送到 facebook 应用程序浏览器中的 opener,但“opener 窗口”从不接收消息。问题的原因是什么?
接收端:
window.addEventListener('message', function (e) {
window.console.log("on message: " + e.data);
}, false)
Run Code Online (Sandbox Code Playgroud)
发送方:
window.opener.postMessage('any Message', document.location.origin);
Run Code Online (Sandbox Code Playgroud) 我在不同的域上有两个网络应用程序。
我的最终目标如下。
我找到了在 Asp.net MVC - 5 中使用 Google 帐户 API 登录的教程。
https://tutorialslink.com/Articles/How-to-login-with-Google-account-API-in-Aspnet-MVC---5/18
通过使用相同的概念,我尝试做以下事情
从 WebApp1 打开 WebApp2
从 WebApp2 应用事件重定向到指定的 URL,其中包含 URL + 加密格式的所需数据。
从 WebApp1 不断检查更新的 URL 并相应地在 WebAp1 上显示数据。
为了实现上述步骤,我的源代码(WebApp1)如下。
var REDIRECT = "http://localhost/Home/Test";
var webApp2 = window.open("WebApp2Url", "CrossDomain", '', true);
var pollTimer = window.setInterval(function () {
try {
if (webApp2.document.URL.indexOf(REDIRECT) != -1) {
window.clearInterval(pollTimer);
// logic to retrieve data from webApp2.document.URL
webApp2.close();
debugger;
}
}
catch (e) {
}
}, 500); …Run Code Online (Sandbox Code Playgroud) 我在堆栈上找不到任何好的答案 - 它们与对话框、文本编辑器有关,并且有人使用 VBScript。
我需要向开窗器发送消息。这在 FF、Chrome 和 Opera 中工作正常,但window.opener在 IE8-10 中为空。
我用来window.open让新窗口出现。
我什至尝试过这个:
var new_window = window.open( url, '_social', "height=600,width=600" );
if ( !new_window.opener ) {
new_window.opener = window;
}
Run Code Online (Sandbox Code Playgroud)
打开的窗口只有一个脚本标签,如下所示:
<script type="text/javascript">
var data = {
type : 'redirect',
destination : '<?= $destination; ?>'
};
window.opener.postMessage( JSON.stringify( data ), '*' );
window.close();
</script>
Run Code Online (Sandbox Code Playgroud)
我打开控制台并记录了window.opener结果为空,所以我认为它与 DOM 是否准备好有任何关系。
该窗口在登陆带有 script 标记的页面之前会重定向几次。
javascript ×7
jquery ×2
popup ×2
asp.net-mvc ×1
facebook ×1
gwt ×1
html ×1
oauth ×1
reactjs ×1
webview ×1
window.open ×1