如何确保打开第二个浏览器窗口/选项卡的浏览器窗口/选项卡在第二个窗口/选项卡关闭后重新获得焦点?

时间:2019-09-05 12:00:42

标签: browser tabs window message

我有一个网络应用程序,该应用程序在一个浏览器窗口/选项卡中显示一个“主要”网页,其中包含一个链接,当用户单击该链接时...

1. Opens another browser window/tab that takes the focus from the 'main' web-page's
   browser window/tab, and ...

   1.a. Displays a form,

   1.b. Collects data,

   1.c. Sends the data back to the server-side php script function with a form get
        action, which then ...

        1.c.i  Loads another page into the second browser window/tab that closes it,

        1.c.ii And now I want the php script function to send a message back to the
               'main' web-page to tell the user that the processing was successful.

  2. The 'main' web-page receives the message and display it in it's
     browser window/tab.

在最后两个步骤中,我已完成所有工作。对于1.c.ii,在关闭第二个浏览器窗口/选项卡之前,我已经在php / Symfony v2.8 flashbag中放入了一条消息。此消息Flashbag可用于“主”网页的服务器端代码,因此,如果可以通过某种方式重新激活服务器端代码或“主”网页的浏览器的窗口/选项卡,则闪回消息可以显示在“主要”网页的浏览器窗口/标签中。

一个想法是,当第二个窗口关闭时,焦点将“回到”先前的浏览器窗口/选项卡,如果该页面是“主”网页,则可能会通过“重新聚焦”唤醒事件,然后对服务器执行ajax调用,请求它返回存储在flashbag中的所有消息。但是,这需要“主”(第一个)网页真正得到关注。如果服务器端功能以某种方式“了解”了“主”网页(第一个)和第二个浏览器窗口/选项卡,则可能可以使用的窗口/选项卡句柄将焦点“发送”回“主要的网页浏览器窗口/标签页在第二个浏览器窗口/标签页关闭时显示?

0 个答案:

没有答案