将数据从弹出窗口传递回javascript [英] Pass data from pop-up window back to javascript

查看:105
本文介绍了将数据从弹出窗口传递回javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在javascript中有一个window.open函数,它可以调用页面.然后,我想从该页面获取数据并将其返回给javascript函数.

I have a window.open function in javascript that calls a page. I then want to grab the data from that page and return it to the javascript function.

有人可以帮我吗?

$("#popup").click(function(e) { 
    var url = $(this).attr('href');
    e.preventDefault();
    window.open(url, 'authWindow', "width=800,height=436");
});

推荐答案

如果弹出页面与您的域在 相同的域中, ,则可以使用窗口.打开器以访问打开器窗口中的数据

If the page in the popup is in the same domain as yours, you can use window.opener to access data of the opener windows

在当前窗口中:

var winopened;
$("#popup").click(function(e) { 
    var url = $(this).attr('href');
    e.preventDefault();
    winopened = window.open(url, 'authWindow', "width=800,height=436");
});

if(winopened) {
  // call a function in the opened window : 
  res = winopened.functionInWindow();

}

希望对您有帮助...

hope it helped ...

这篇关于将数据从弹出窗口传递回javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆