简体   繁体   English

如何捕获弹出窗口中显示的数据

[英]How to capture data displayed on a pop up window

I have a web application where the user selects some options on the web page and clicks 'submit' button. 我有一个Web应用程序,用户在其中选择网页上的某些选项,然后单击“提交”按钮。 On clicking the submit button, the app queries a DB and displays the results in a pop-up window . 单击提交按钮后,应用程序将查询数据库,并在弹出窗口中显示结果。 Now, I have a strange requirement to capture the data that is displayed in the pop up window and save it in another DB. 现在,我有一个奇怪的要求,即要捕获弹出窗口中显示的数据并将其保存在另一个DB中。 My question here is, how to get hold of the data that is displayed in the pop-up window. 我的问题是,如何获取弹出窗口中显示的数据。 I am very new to this kind of stuff and im clueless about how to proceed. 我对这种东西很陌生,对如何进行一无所知。

Ill explain the above scenario with the help of an example. 我将借助一个示例来说明上述情况。

Lets say, the user enters his name in the webpage and clicks submit. 可以说,用户在网页中输入他的名字,然后单击提交。 On submit, the DB is queried and the age of that particular person is displayed in the pop up. 提交后,将查询数据库,并在弹出窗口中显示该特定人员的年龄。 Now, I have to capture the value of age and save it another DB. 现在,我必须捕获age的值并将其保存到另一个DB。

The open method in javascript for creating a pop-up window returns the object for accessing the DOM of that popup window. javascript中用于创建弹出窗口的open方法返回用于访问该弹出窗口的DOM的对象。 You can use this object to access to contents of the pop-up window. 您可以使用此对象访问弹出窗口的内容。

See: http://www.w3schools.com/jsref/met_win_open.asp 请参阅: http//www.w3schools.com/jsref/met_win_open.asp

When the DB returns the value for the first query (age in your case), instead of displaying the data, first store the value in some variable. 当数据库返回第一个查询的值(在您的情况下为年龄)时,不显示数据,而是将值存储在某个变量中。 Now, fire another query for storing the fetched data (age). 现在,触发另一个查询以存储获取的数据(年龄)。 After the second query is completed ie the age is saved in the DB, you can display the age as you are doing it right now. 第二个查询完成后,即已将年龄保存在数据库中,您可以立即显示年龄。

Hope this helps !!! 希望这可以帮助 !!!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM