如何将值从弹出窗口传递给父窗口作为变量 [英] how to passing value from popup to the parent window as a variable

查看:52
本文介绍了如何将值从弹出窗口传递给父窗口作为变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将值从弹出窗口传递给父窗口作为变量

我可以在父窗口中访问和处理变量(字符串)?


例如从弹出页面,我们有var_from_popup =" abc",弹出窗口

关闭,然后从父窗口,我们可以使用alert(var_from_popup)和

它会向我们显示abc?

how to passing value from popup to the parent window as a variable
which I can access and process the variable(string) in parent window?

such as from popup page, we have var_from_popup="abc", after the popup
closed, then from parent window, we can use alert(var_from_popup) and
it will show us the "abc"?

推荐答案

使用window.opener来引用父项,然后你可以在父窗口中设置你想要的任何变量。
Use window.opener to refer to the parent, then you can set whatever variable you wish in the parent window.


主窗口中有一个变量var varwindow;

弹出的
,我设置

window.opener。 varwindow =" abc"


然后从主窗口,我使用alert(varwindow)但

它写为underfinded"但不是abc..为什么?
there is a variable var varwindow in primary window;

from popup, i set
window.opener.varwindow="abc"

then from primary window , i use alert(varwindow) but
it write as "underfinded" but not "abc"..why?


尝试
展开 | 选择 | Wrap | 行号


这篇关于如何将值从弹出窗口传递给父窗口作为变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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