将数据发送到单独的窗口javascript [英] Send data to separate window javascript
本文介绍了将数据发送到单独的窗口javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用以下命令从现有页面创建了一个新的弹出窗口:
I created a new popup window from an existing page using:
window.open("myUrl","myName","width=200,height=200");
现在在弹出窗口中我有一个文本输入和一个按钮,我想创建一个onclick方法对于将文本输入值发送到创建弹出窗口而不使用表单或php的页面的按钮,这可能吗?
Now on that popup window I have a text input and a button, I want to create an onclick method for the button that sends the text inputs value to the page that created the popup without using a form or php, is this possible?
推荐答案
你可以使用 window.opener 关键字
假设你有一个javascript方法doSomething(value){....} in您的父类,然后从您的POPUP,您可以使用
lets say you have a javascript method doSomething(value){....} in your parent class, then from your POPUP you can call the parent function using
window.opener.doSomething("here is my data from child sent to parent");
更新
这篇关于将数据发送到单独的窗口javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文