当从一个网站打开选项卡时,如何在浏览器选项卡中进行通信 [英] How to communicate in tabs of browsers , when tab is opened from one website

查看:75
本文介绍了当从一个网站打开选项卡时,如何在浏览器选项卡中进行通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个MVC应用程序,我在这个应用程序上有按钮(我们称这个网站为A)。点击

那个按钮,我在新标签中打开另一个网站(让我们称这个网站为B)(这不是我的网站,我不知道这个内部的实现网站)

我有以下问题,

1)我将在网站A标签上显示加载图片,直到用户在网站B上工作。当网站B的标签关闭时,我想继续我的网站(网站A)。

那么我怎么知道另一个标签何时关闭?

2)在提交网站B时,它会调用网站A的Action方法。但是我在这个动作方法中编写的任何内容都会在第二个标签中执行。

如何让它运行在初始浏览器选项卡中?



我尝试过:



我我试图通过OnBeforeUnload的javascript捕获标签,但是在标签2中有完全独立的应用程序我无法通知应用程序附近的标签(因为我无法更改第二个应用程序的代码)

I have a MVC application, I have button on this application (lets call this web site as "A"). On the click of
that button , I am opening another website(lets call this web site as "B") in new tab(This is not my website, I don't know internal implementation of this website)
I have below issues,
1) I will be showing loading image on website "A" tab until user works on Website "B" . I want to continue with my website (web site "A") when tab with website "B" is closed.
So how will I come to know when another tab is closed?
2) On submit of website B it will call Action method of web site A. But then anything I write in this action method is getting executed in second tab.
How can I make it run in initial browser tab?

What I have tried:

I have tried to catch tab close by OnBeforeUnload of javascript but as in tab 2 there is totally separate application I am not able to notify tab close to application (as I cant change the code of 2nd application)

推荐答案

1)你不可能知道这个



2)我不明白当你在你的网站上调用一个动作时说网站没有连接。无论如何,如果你给浏览器标签A一个名字,你可以这样做,并且网站B上的表格需要将它的表格的目标设置为标签a的名称,它*应该*提交到该标签,但是这可能不适用于所有浏览器,因为你没有自己的网站BI,所以看不出你如何做这个改变。



我看不到你为了解决这个问题,出于安全原因,跨浏览器通常会在浏览器中故意限制。
1) You can't know this

2) I don't understand how it is calling an action on your site when you say the sites are not connected. Anyway you can do this if you give the browser tab A a name, and the form on site B needs to set the "target" of it's form to be the name of tab a, and it *should* submit to that tab, but this might not work on all browsers, and as you don't own site B I don't see how you can make this change.

I can't see you ever getting this to work, cross-site interaction is usually limited deliberately in browsers for security reasons.


这篇关于当从一个网站打开选项卡时,如何在浏览器选项卡中进行通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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