Tab page communication method and device, server and storage medium

By using SharedWorker and iframe to directly pass messages between browser tabs, the problem of low communication efficiency and high server overhead under the same-origin policy restriction is solved, and fast, low-complexity tab communication is achieved.

CN116069522BActive Publication Date: 2026-02-24UBTECH ROBOTICS CORP LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211716353.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-29
Publication Date
2026-02-24
Estimated Expiration
2042-12-29

AI Technical Summary

Technical Problem

In existing technologies, communication between browser tabs requires a server as an intermediary due to the same-origin policy, resulting in low communication efficiency and high server overhead, especially when there are many users.

Method used

The system uses a shared thread, SharedWorker, to receive messages from tabs and transmits operation information directly between different tabs through a port filtering mechanism, avoiding the need for a server as an intermediary. It utilizes SharedWorker and iframe for cross-domain communication.

Benefits of technology

It enables fast communication between browser tabs, saves server overhead, reduces communication complexity, does not depend on other resources, and requires no plugins.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116069522B_ABST
    Figure CN116069522B_ABST
Patent Text Reader

Abstract

The application relates to a communication method and device of a tab page, a server and a storage medium. The method comprises the following steps: a shared thread SharedWorker receives a message sent by a first tab page through a first embedded web page iframe, the message comprises source domain name information corresponding to a target subpage opened by the first tab page and operation information performed on the target subpage; in a plurality of SharedWorker object ports, a first port connected with the first embedded web page iframe is determined, and port screening is performed based on the first port to obtain a second port connected with a second embedded web page iframe corresponding to a second tab page; and the source domain name information and the operation information are distributed to the corresponding second tab page through the second port and the corresponding second embedded web page iframe. Through the application, the problem that a server is used as a medium to perform communication between tab pages in related technologies, thereby causing large server overhead, is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of browser browsing technology, and in particular to a communication method, device, server, and storage medium for tabs. Background Technology

[0002] In related technologies, a browser can open a subpage in a new tab, or the user can directly enter the address in the browser to open a new subpage. However, since the subpages to be opened belong to tabs of different source domains, the operation information generated by the operation needs to be notified to other pages after an operation is performed on the corresponding subpage. Therefore, communication between different tabs is required.

[0003] In related technologies, different tabs communicate based on the same-origin policy. However, under the restriction of the same-origin policy, tabs under different domains cannot be implemented using simple local storage or session tracking technology cookies. Instead, a server is needed as an intermediary, and asynchronous JavaScript and XML (Asynchronous JavaScript and XML, or AJAX for short) or the full-duplex TCP-based WebSocket communication protocol is used for communication between tabs. At the same time, due to the impact of server performance and network performance, the method of using a server as an intermediary and using AJAX requests or WebSockets for communication results in high latency, high server overhead when there are many users, and poor communication efficiency between tabs.

[0004] There is currently no better technical solution to the problem of high server overhead caused by using a server as an intermediary for communication between tabs in related technologies. Summary of the Invention

[0005] This application provides a communication method, apparatus, server, and storage medium for tabs, to at least solve the problem of high server overhead caused by using a server as a medium for communication between tabs in related technologies.

[0006] In a first aspect, this application provides a communication method for tabs, comprising: a shared thread SharedWorker receiving a message sent by a first tab through a first embedded webpage iframe, wherein the message includes source domain information corresponding to a target subpage opened by the first tab and operation information performed on the target subpage; the SharedWorker determining a first port connected to the first embedded webpage iframe among multiple associated SharedWorker object ports, and performing port filtering based on the first port to obtain a second port connected to a second embedded webpage iframe corresponding to a second tab; the SharedWorker distributing the source domain information and the operation information to the corresponding second tab through the second port and the corresponding second embedded webpage iframe, so that a target tab with the target subpage among multiple second tabs receives the operation information transmitted by the corresponding second embedded webpage iframe.

[0007] Secondly, this application provides a tab communication device, including a shared thread SharedWorker, wherein the SharedWorker includes:

[0008] The receiving module is used to receive a message sent by the first tab through the first embedded webpage iframe, wherein the message includes source domain information corresponding to the target subpage opened by the first tab and operation information performed on the target subpage;

[0009] The determination module is used to determine the first port connected to the first embedded web page iframe among multiple associated SharedWorker object ports, and to perform port filtering based on the first port to obtain the second port connected to the second embedded web page iframe corresponding to the second tab.

[0010] The processing module is configured to distribute the source domain name information and the operation information to the corresponding second tab page through the second port and the corresponding second embedded web page iframe, so that the target tab page with the target subpage among the multiple second tab pages receives the operation information transmitted by the corresponding second embedded web page iframe.

[0011] Thirdly, a server is provided, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;

[0012] Memory, used to store computer programs;

[0013] When a processor executes a program stored in memory, it implements the steps of the tab communication method described in any embodiment of the first aspect.

[0014] Fourthly, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps of the tab communication method as described in any embodiment of the first aspect.

[0015] Compared with related technologies, this embodiment provides a communication method, device, server, and storage medium for tabs. A shared thread (SharedWorker) receives messages sent by a first tab via a first embedded webpage (iframe). These messages include source domain information corresponding to a target subpage opened by the first tab and operation information performed on that target subpage. Among multiple associated SharedWorker object ports, a first port connected to the first embedded webpage (iframe) is determined, and port filtering is performed based on this first port to obtain a second port connected to a second embedded webpage (iframe) corresponding to a second tab. Through the second port and the corresponding second embedded webpage (iframe), the source domain information and the operation information are distributed to the corresponding second tab, enabling the target tab with the target subpage to receive the operation information transmitted by the corresponding second embedded webpage (iframe). This solves the problem of high server overhead caused by server-mediated communication between tabs in related technologies, achieving fast communication between different browser tabs, saving server overhead, eliminating the need for plugin installation, and reducing the complexity of tab communication.

[0016] Details of one or more embodiments of this application are set forth in the following drawings and description to make other features, objects and advantages of this application more readily apparent. Attached Figure Description

[0017] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0018] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1 A flowchart illustrating a communication method for a tab page provided in an embodiment of this application;

[0020] Figure 2 This is a flowchart illustrating a communication method for a tab page according to a preferred embodiment of this application;

[0021] Figure 3 A schematic diagram illustrating communication between tabs in a preferred embodiment of this application;

[0022] Figure 4 This is a structural block diagram of a communication device for a tab page provided in an embodiment of this application;

[0023] Figure 5 This is a schematic diagram of the server structure according to an embodiment of this application. Detailed Implementation

[0024] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0025] Before providing a detailed description of the embodiments of this application, the relevant technical features involved in the embodiments of this application are explained below:

[0026] JavaScript (JS for short) is a lightweight, interpreted or just-in-time (JIT) programming language with a function-first approach. As a scripting language for developing web pages, JS is also used in many non-browser environments. JavaScript is a prototype-based, multi-paradigm dynamic scripting language that supports object-oriented, imperative, declarative, and functional programming paradigms.

[0027] A web worker is a JavaScript thread that runs in the background and does not affect the page's responsiveness. Web workers include two types of threads: dedicated threads (Dedicated Worker) and shared threads (Shared Worker).

[0028] SharedWorker is a type of Web Worker that can be shared by all pages from the same origin. Similar to the Web Worker application API, you can register a SharedWorker instance by passing in the JavaScript Uniform Resource Locator (URL).

[0029] PostMessage is a commonly used function in the Windows Application Programming Interface (API) used to put a message into a message queue. Messages in the message queue are retrieved by calling GetMessage and PeekMessage.

[0030] HTML5 is a language for describing web content. It is the next-generation standard for the internet and a language for building and presenting internet content.

[0031] An iframe is an HTML tag that acts as a document within a document, or a floating frame. The iframe element creates an inline frame that contains another document.

[0032] The technical solutions in the embodiments of this application will now be described with reference to the accompanying drawings.

[0033] Figure 1 This is a flowchart illustrating a communication method for a tab page provided in an embodiment of this application. Figure 1 As shown in the figure, this application embodiment provides a communication method for tabs, which includes the following steps:

[0034] In step S101, the SharedWorker thread receives a message sent by the first tab through the first embedded webpage iframe. The message includes the source domain information corresponding to the target subpage opened in the first tab and the operation information performed on the target subpage.

[0035] The communication method in this embodiment involves a message sending method from a first tab in a browser to other tabs (defined as second tabs). In this embodiment, a shared thread SharedWorker (also known as a shared worker) is used to perform message distribution and filtering, and push messages to the host (corresponding target tab) through the corresponding embedded web page iframe.

[0036] In this embodiment, cross-domain communication can be achieved using tab pages and iframes via postMessage and message event listening. Specifically, the first tab page uses the corresponding iframe and uses postMessage and message event listening to send messages with the shared thread SharedWorker and other tab pages (e.g., the second tab page).

[0037] In this embodiment, after creating a SharedWorker, a corresponding SharedWorker object window is created and assigned to the corresponding tab. The SharedWorker starts the corresponding SharedWorker object window (i.e., the first port) by calling the worker.port.start() method, and listens for messages returned by the first port through the message event, thereby obtaining the messages sent by the first tab. In the JS of the SharedWorker, the SharedWorker object window (including the first port and the second port) connected to the SharedWorker is obtained through the connect event. The SharedWorker can start the SharedWorker object window and listen for the message event by calling worker.port.start(), and store the SharedWorker object window using an array or Map.

[0038] In this embodiment, when the first tab needs to send a message to the host tab (one or more of the second tabs, which are also the tabs corresponding to the domain to which the opened target subpage belongs), it calls postMessage to send the corresponding message to the first embedded web page iframe. After receiving the corresponding message, the first embedded web page iframe sends the received message to the shared thread SharedWorker through the worker.port.postMessage method, specifically to the script file corresponding to the shared thread SharedWorker.

[0039] In step S102, SharedWorker determines the first port connected to the first embedded web page iframe among the multiple associated SharedWorker object ports, and performs port filtering based on the first port to obtain the second port connected to the second embedded web page iframe corresponding to the second tab.

[0040] In this embodiment, after receiving the corresponding message, the script file corresponding to the SharedWorker of the shared thread iterates through the ports of multiple SharedWorker objects associated with the SharedWorker, filters out multiple second ports that are not the first port, and then enables the sending of messages to multiple second ports so that the second embedded web page iframe corresponding to the second port receives the message and sends it to the corresponding second tab after receiving the message.

[0041] In step S103, SharedWorker distributes the source domain name information and operation information to the corresponding second tab through the second port and the corresponding second embedded web page iframe, so that the target tab with the target subpage among the multiple second tabs receives the operation information transmitted by the corresponding second embedded web page iframe.

[0042] In this embodiment, the target tab includes at least one of multiple second tabs; SharedWorker calls postMessage to send a corresponding message to the second embedded web page iframe. After receiving the corresponding message, the second embedded web page iframe sends the received message to the corresponding second tab through the worker.port.postMessage method. The second tab can receive the message sent by the first tab by receiving the message reception event. In this way, the target tab is aware of the operation performed on the target subpage.

[0043] Through steps S101 to S103, a shared thread (SharedWorker) receives messages sent by the first tab through the first embedded webpage (iframe). These messages include source domain information corresponding to the target subpage opened in the first tab and operation information performed on the target subpage. Among the multiple associated SharedWorker object ports, a first port connected to the first embedded webpage (iframe) is determined, and port filtering is performed based on this first port to obtain a second port connected to the second embedded webpage (iframe) corresponding to the second tab. Through the second port and the corresponding second embedded webpage (iframe), the source domain information and operation information are distributed to the corresponding second tab, enabling the target tab with the target subpage among multiple second tabs to receive the operation information transmitted by the corresponding second embedded webpage (iframe). This solves the problem of high server overhead caused by using a server as a medium for communication between tabs in related technologies. It achieves fast communication between different browser tabs, saves server overhead, eliminates the need for plugin installation, and reduces the complexity of tab communication.

[0044] It should be noted that the tab communication method in this application embodiment utilizes the postMessage and message event listening functions between the tab and the iframe for cross-domain communication. Simultaneously, SharedWorker allows the creation of a shared process object within the same-origin page, enabling message distribution via this shared thread. This communication method allows for fast tab communication across different browser tabs and different origin domains, solving the problem of high server overhead associated with server-mediated tab communication in related technologies, thus saving resources. Furthermore, this communication method does not require plugin installation, reducing the complexity of tab communication. After initialization, this communication method operates entirely locally, without relying on other resources. Moreover, message distribution within SharedWorker facilitates easier message processing and validation.

[0045] In some embodiments, SharedWorker determines the first port connected to the first embedded web page iframe from among multiple associated SharedWorker object ports by the following steps: SharedWorker traverses multiple SharedWorker object ports through a preset script file, and obtains the SharedWorker object port corresponding to the first embedded web page iframe through a preset connection event, thereby determining the first port connected to the first embedded web page iframe.

[0046] In this embodiment, connection events include, but are not limited to, the connect event; in this embodiment, the SharedWorker listens for a message reception event on the first port, that is, after the script file corresponding to the SharedWorker receives the message sent by the first tab through the first embedded webpage, the script file corresponding to the SharedWorker traverses the ports of multiple SharedWorker objects associated with the SharedWorker, filters out multiple second ports that are not the first port, and thus enables the sending of messages to multiple second ports.

[0047] In this embodiment, SharedWorker determines the corresponding first port by listening to the corresponding message receiving event, and filters out the second port that is not the first port, thereby determining the host to which the message will be sent, that is, the target tab.

[0048] In some embodiments, before obtaining the SharedWorker object port corresponding to the first embedded web page iframe through a preset connection event and determining the first port connected to the first embedded web page iframe, the following steps are also performed: SharedWorker opens multiple SharedWorker object ports and listens for message receiving events on each SharedWorker object port to receive messages sent by the first tab through the first embedded web page iframe from the first port. The message receiving event is used to indicate whether the first embedded web page iframe has obtained the messages sent by the first tab.

[0049] In this embodiment, SharedWorker needs to open the associated SharedWorker object port to listen for message events. While determining the first port, it also receives messages sent by the first tab and thus determines the host to which the received messages need to be sent, which is the target tab among multiple second tabs. This enables fast communication between tabs without the need for a server as an intermediary, reducing server overhead.

[0050] In some embodiments, port filtering is performed based on the first port to obtain the second port connected to the second embedded web page iframe corresponding to the second tab. This is achieved through the following steps: SharedWorker traverses multiple SharedWorker object ports and filters out all SharedWorker object ports except the first port to obtain the second port connected to the second embedded web page iframe corresponding to the second tab.

[0051] In this embodiment, by traversing multiple SharedWorker object ports, that is, listening to whether there is a message receiving event on the corresponding SharedWorker object port, when a corresponding message receiving event is detected, the corresponding SharedWorker object port is designated as the first port, and the other ports are designated as the second port.

[0052] In some embodiments, before SharedWorker distributes the source domain name information and operation information to the corresponding second tab through the second port and the corresponding second embedded web page iframe, the following steps are also performed: SharedWorker opens the second port corresponding to each second tab.

[0053] In this embodiment, after determining the second port for sending messages, to ensure that the message is sent via the postMessage method and that the corresponding second embedded webpage (iframe) listens for message reception events to receive the message, it is necessary to ensure that the corresponding second port is open. Although SharedWorker opens all SharedWorker object ports when receiving messages sent from the first tab, in this embodiment, the second port corresponding to each second tab is reopened to ensure that the corresponding second port is open, and then the message is sent via postMessage and listening for message reception events.

[0054] The communication method of the tab page according to the preferred embodiment of this application will be further described below:

[0055] The communication method in this application encapsulates an initialization method, a message sending method, and a message receiving event. During initialization, an embedded webpage iframe is inserted into the tab page, and an iframe D that undertakes the message communication task is introduced. iframe D listens to the window's message event to receive messages sent by the page, and creates a shared thread SharedWorker. The shared thread SharedWorker returns a SharedWorker object, and then calls the worker.port.start() method to start the SharedWorker object port, and listens for messages returned by the corresponding SharedWorker object port through the message event. In the JS of SharedWorker, the SharedWorker object port associated with the SharedWorker can be obtained through the connect event, and the SharedWorker object port can be started and the message event can be listened to by calling worker.port.start(), and the SharedWorker object port can be stored using an array or Map. Figure 2 This is a flowchart illustrating a communication method for a tab page according to a preferred embodiment of this application, with reference to... Figure 2 The initialization process includes the following steps:

[0056] Step S21: The tab is loaded, then steps S22 and S23 are executed.

[0057] Step S22: Call the initialization method, and then execute step S24.

[0058] Step S23: Listen for message reception events.

[0059] Step S24: Insert an embedded webpage iframe, then proceed to step S25.

[0060] Step S25: Create a SharedWorker object inside the embedded webpage iframe, and then execute step S26.

[0061] Step S26: Open the SharedWorker object port in the embedded web page iframe and listen for port message reception events. Then, execute step S27.

[0062] Step S27: The script SharedWorkerGlobalScope corresponding to the SharedWorker thread opens the SharedWorker object port, listens for message receiving events, and stores the SharedWorker object port.

[0063] Figure 3 This is a schematic diagram illustrating communication between tabs in a preferred embodiment of this application, with reference to... Figure 3 The preferred implementation of this application includes the following communication process between tabs: When tab A calls the communication method of this application embodiment, it sends a message to the embedded webpage iframe D by calling postMessage. After receiving the message, the embedded webpage iframe D sends the message to the SharedWorker script SharedWorkerGlobalScope through the worker.port.postMessage method. After the script SharedWorkerGlobalScope receives the message, it iterates through the stored SharedWorker object ports and then sends the message to the second port that is not the first port. At this time, the embedded webpage iframe D in other tabs (e.g., tab B, tab C) will receive the corresponding message. Then, the corresponding embedded webpage iframe D sends a message to the corresponding tab (e.g., tab B, tab C), and the message receiving event of the tab (e.g., tab B, tab C) can receive the message sent by tab A. In this embodiment, the corresponding source domain name can be passed in when the tab sends or receives a message, so as to perform distribution filtering when SharedWorker distributes messages and to process messages when the embedded webpage iframe D pushes messages to the host.

[0064] This embodiment also provides a communication device for a tab page, which is used to implement the above embodiments and preferred embodiments; details already described will not be repeated. The terms "module," "unit," "subunit," etc., used below refer to combinations of software and / or hardware that implement a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.

[0065] Figure 4 This is a structural block diagram of a communication device for a label provided in an embodiment of this application, such as... Figure 4 As shown, this application embodiment provides a tab communication device, including a shared thread SharedWorker, which includes:

[0066] The receiving module 41 is used to receive a message sent by the first tab through the first embedded webpage iframe, wherein the message includes the source domain information corresponding to the target subpage opened in the first tab and the operation information performed on the target subpage.

[0067] The determining module 42, coupled to the receiving module 41, is used to determine the first port connected to the first embedded web page iframe among the multiple associated SharedWorker object ports, and to perform port filtering based on the first port to obtain the second port connected to the second embedded web page iframe corresponding to the second tab.

[0068] The processing module 43, coupled to the determining module 42, is used to distribute source domain name information and operation information to the corresponding second tab page through the second port and the corresponding second embedded web page iframe, so that the target tab page with the target subpage among the multiple second tab pages receives the operation information transmitted by the corresponding second embedded web page iframe.

[0069] The tab communication device of this application embodiment uses a shared thread, SharedWorker, to receive messages sent by a first tab through a first embedded webpage iframe. The messages include source domain information corresponding to the target subpage opened by the first tab and operation information performed on the target subpage. Among multiple associated SharedWorker object ports, a first port connected to the first embedded webpage iframe is determined, and port filtering is performed based on the first port to obtain a second port connected to the second embedded webpage iframe corresponding to the second tab. Through the second port and the corresponding second embedded webpage iframe, the source domain information and operation information are distributed to the corresponding second tab, enabling the target tab with the target subpage among multiple second tabs to receive the operation information transmitted by the corresponding second embedded webpage iframe. This solves the problem of high server overhead caused by using a server as a medium for communication between tabs in related technologies, achieving fast communication between different browser tabs, saving server overhead, eliminating the need for plugin installation and other resource dependencies, and reducing the complexity of tab communication.

[0070] In some embodiments, SharedWorker is also used to traverse multiple SharedWorker object ports through a preset script file, and obtain the SharedWorker object port corresponding to the first embedded web page iframe through a preset connection event, and determine the first port connected to the first embedded web page iframe.

[0071] In some embodiments, SharedWorker further includes a listening module, which is used to open multiple SharedWorker object ports and listen for message receiving events on each SharedWorker object port to receive messages sent by the first tab through the first embedded web page iframe from the first port. The message receiving event is used to indicate whether the first embedded web page iframe has obtained the message sent by the first tab.

[0072] In some embodiments, SharedWorker is also used to traverse multiple SharedWorker object ports and filter out all SharedWorker object ports except the first port to obtain a second port connected to the second embedded webpage iframe corresponding to the second tab.

[0073] In some embodiments, before SharedWorker distributes the source domain name information and operation information to the corresponding second tab through the second port and the corresponding second embedded web page iframe, SharedWorker is also used to open the second port corresponding to each second tab.

[0074] Figure 5 This is a schematic diagram of the server structure according to an embodiment of this application, as shown below. Figure 5 As shown in the figure, this application embodiment provides a server, including a processor 51, a communication interface 52, a memory 53, and a communication bus 54, wherein the processor 51, the communication interface 52, and the memory 53 communicate with each other through the communication bus 54.

[0075] Memory 53 is used to store computer programs;

[0076] When processor 51 executes the program stored in memory 53, it implements... Figure 1 The methods and steps in the text.

[0077] The processing implementation in this server Figure 1 The method steps described above, and the resulting technical effects, are the same as those achieved in the embodiments described above. Figure 1 The technical effects of the communication method used in the tabs are the same, so they will not be elaborated here.

[0078] The communication bus mentioned in the above server can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 5 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0079] The communication interface is used for communication between the aforementioned server and other devices.

[0080] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0081] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0082] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the tab communication method provided in any of the foregoing method embodiments.

[0083] In another embodiment provided in this application, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to perform the steps of the tab communication method described in any of the above embodiments.

[0084] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive elements that are not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0085] The above description is merely a specific embodiment of the present invention, enabling those skilled in the art to understand or implement the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the present invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A communication method for tabs, characterized in that, include: The SharedWorker thread receives a message sent by the first tab through the first embedded webpage iframe, wherein the message includes the source domain information corresponding to the target subpage opened by the first tab and the operation information performed on the target subpage; The SharedWorker determines the first port connected to the first embedded web page iframe among the multiple associated SharedWorker object ports, and performs port filtering based on the first port to obtain the second port connected to the second embedded web page iframe corresponding to the second tab. The SharedWorker distributes the source domain name information and the operation information to the corresponding second tab page through the second port and the corresponding second embedded web page iframe, so that the target tab page with the target subpage among the multiple second tab pages receives the operation information transmitted by the corresponding second embedded web page iframe; Specifically, among the multiple associated SharedWorker object ports, the first port connected to the first embedded webpage iframe is determined, including: The SharedWorker uses a preset script file to traverse multiple SharedWorker object ports and obtains the SharedWorker object port corresponding to the first embedded web page iframe through a preset connection event, thereby determining the first port connected to the first embedded web page iframe. Before obtaining the SharedWorker object port corresponding to the first embedded web page iframe through a preset connection event and determining the first port connected to the first embedded web page iframe, the method further includes: the SharedWorker opening multiple SharedWorker object ports and listening for message receiving events on each SharedWorker object port to receive the message sent by the first tab through the first embedded web page iframe from the first port, wherein the message receiving event is used to indicate whether the first embedded web page iframe has obtained the message sent by the first tab.

2. The method according to claim 1, characterized in that, The connection events include the connect event.

3. The method according to claim 1, characterized in that, Based on the first port, port filtering is performed to obtain the second port for the connection of the second embedded webpage iframe corresponding to the second tab, including: The SharedWorker iterates through multiple SharedWorker object ports and filters out all SharedWorker object ports that exclude the first port to obtain the second port connected to the second embedded webpage iframe corresponding to the second tab.

4. The method according to claim 1, characterized in that, Before SharedWorker distributes the source domain name information and the operation information to the corresponding second tab page through the second port and the corresponding second embedded web page iframe, the method further includes: SharedWorker opening the second port corresponding to each second tab page.

5. A tabbed communication device, comprising a shared thread SharedWorker, characterized in that, The SharedWorker includes: The receiving module is used to receive a message sent by the first tab through the first embedded webpage iframe, wherein the message includes source domain information corresponding to the target subpage opened by the first tab and operation information performed on the target subpage; The determination module is used to determine the first port connected to the first embedded web page iframe among multiple associated SharedWorker object ports, and to perform port filtering based on the first port to obtain the second port connected to the second embedded web page iframe corresponding to the second tab. The processing module is configured to distribute the source domain name information and the operation information to the corresponding second tab page through the second port and the corresponding second embedded web page iframe, so that the target tab page with the target subpage among the multiple second tab pages receives the operation information transmitted by the corresponding second embedded web page iframe; The SharedWorker is also used to traverse multiple SharedWorker object ports through a preset script file, and obtain the SharedWorker object port corresponding to the first embedded web page iframe through a preset connection event, and determine the first port connected to the first embedded web page iframe. The SharedWorker further includes a listening module, which is used to open multiple SharedWorker object ports and listen for message receiving events on each SharedWorker object port to receive the message sent by the first tab through the first embedded web page iframe from the first port. The message receiving event is used to indicate whether the first embedded web page iframe has obtained the message sent by the first tab.

6. A server, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, when executing a program stored in memory, implements the steps of the tab communication method according to any one of claims 1-4.

7. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the tab communication method as described in any one of claims 1-4.

Citation Information

Patent Citations

  • Page information processing method and system

    CN107688570A

  • Method for communicating among multiple tabs of browser and updating state

    CN114385956A