[英]Pass data between two web pages on the same machine with no postback
I am creating a web page that offers the user the ability to "undock" a control into a new browser window. 我正在创建一个网页,使用户能够将控件“取消停靠”到新的浏览器窗口中。 When the user selects a value in the new window, I need to have the new page pass data to the parent page and update some information on the screen.
当用户在新窗口中选择一个值时,我需要让新页面将数据传递到父页面并更新屏幕上的某些信息。 Basically, I need to keep the data displayed in sync.
基本上,我需要保持数据同步显示。 I am using jQuery and AJAX to avoid any postbacks and I would want to do the same for this.
我正在使用jQuery和AJAX来避免任何回发,并且我想对此做同样的事情。 For example: The user does a search for "foo" on parent page and wants to see the results in a larger format.
例如:用户在父页面上搜索“ foo”,并希望以更大的格式查看结果。 He clicks the "undock" button and larger window opens with the search results.
他单击“取消停靠”按钮,随即打开带有搜索结果的较大窗口。 The user selects a value from the child window and the parent window is updated as well.
用户从子窗口中选择一个值,并且父窗口也将更新。 I would think I could accomplish this with AJAX but have yet to find a good post explaining it.
我想我可以使用AJAX来完成此任务,但尚未找到解释它的好文章。 Does anyone know how this can be done?
有谁知道该怎么做?
Also, if the child windows gets closed and I don't capture the close because of a browser crash, is there a way the parent can check to see if the child is still there? 另外,如果子窗口关闭并且由于浏览器崩溃而我没有捕获到该关闭,那么父母可以通过一种方法检查子窗口是否仍然存在吗?
Thanks! 谢谢!
您可以尝试使用socket.io ,但是对于您的情况来说可能会过分...
check out, if this works for you: 查看是否适合您:
http://www.wintellect.com/CS/blogs/jprosise/archive/2011/03/10/using-html5-web-storage-for-interprocess-communication.aspx http://www.wintellect.com/CS/blogs/jprosise/archive/2011/03/10/using-html5-web-storage-for-interprocess-communication.aspx
cheers sascha 欢呼声
您不能在子窗口中使用window.parent吗?
To do your undock, are you using window.open? 要取消停靠,您是否正在使用window.open? You can use window.opener to communicate between two windows: http://www.w3schools.com/jsref/prop_win_opener.asp
您可以使用window.opener在两个窗口之间进行通信: http : //www.w3schools.com/jsref/prop_win_opener.asp
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.