你怎么2浏览器标签/窗口之间沟通? [英] How do you communicate between 2 browser tabs/windows?

查看:148
本文介绍了你怎么2浏览器标签/窗口之间沟通?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个启动作为一个新的浏览器窗口/标签第二web应用的web应用程序。我想,当用户提交的第二页上输入自己的更新原始页面上的内容。

I have a web application that launches as second web application in a new browser window / tab. I want to update the content on the original page when the user submits their input on the second page.

真实世界的实例:
谷歌使用GMail中的这种行为。当撰写新邮件,如果您单击收件人链接它带来了你在一个新的浏览器窗口中的联系人列表。这使得原来的撰写电子邮件窗口打开并激活的输入,同时用户可以在任何时候选择联系人列表中的电子邮件收件人。当他们提交窗口中选定的电子邮件地址添加到原撰写窗口收件人列表。

Real World Example: Google uses this behavior in GMail. When composing a new message if you click the "To" link it brings up a list of your contacts in a new browser window. This leaves the original compose email window open and active for input while the user can at any time select the email recipients from the list of contacts. When they submit that window the selected email addresses are added to the recipient list in the original compose window.

这是如何实现的呢?我想它可以使用AJAX进行,但理想的解决方案将避免通过服务器所需的路由它往返/编程逻辑。

How is this accomplished? I imagine it could be done using AJAX but ideally the solution will avoid the round trip / programming logic required to route it via the server.

有关参考我的这个技术栈是一个ASP.NET MVC应用程序启动第二ASP.NET MVC应用程序包含一个Silverlight应用程序。这两个应用程序能/不使使用jQuery的。

For reference my technology stack for this is an ASP.NET MVC App launching a second ASP.NET MVC App that contains a Silverlight App. Both applications can / do make use of jQuery.

感谢您的帮助。

推荐答案

我不认为你的意思是两个标签。什么是Gmail做的是一个弹出和家长之间的通信。

I don't think you mean two tabs. What Gmail is doing is communicating between a pop up and the parent.

因此​​,让我们说你打开使用JavaScript的新窗口。在打开的窗口中,你可以做:

So let's say you opened a new window using javascript. In the opened window you can do:

opener.someFunction()传回数据。让我找到了坚实的例子并粘贴。

opener.someFunction() to pass data back. Let me find a solid example and paste it.

编辑:这里是一个很好exmample。 <一href=\"http://www.javascriptkit.com/javatutors/remote2.shtml\">http://www.javascriptkit.com/javatutors/remote2.shtml

Here is a good exmample. http://www.javascriptkit.com/javatutors/remote2.shtml

您可以用揭幕战做了很多。

You can use the opener to do a lot.

这篇关于你怎么2浏览器标签/窗口之间沟通?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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