Function calling method and terminal

CN122534281APending Publication Date: 2026-08-07JUHAOKAN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
JUHAOKAN TECH CO LTD
Filing Date
2026-03-26
Publication Date
2026-08-07

AI Technical Summary

Technical Problem

[0004]但是,由于跨域通信接口仅提供基础消息传递能力,开发者为实现跨域函数调用,需手动实现完整的消息订阅/发布机制,针对不同的函数调用场景,则需要重复编写消息订阅、类型判断、参数封装等样板代码,开发效率较低

Benefits of technology

[0050]接收模块,用于接收到所述第二窗口通过所述跨域通信接口发送的第二通信消息后,在所述第二通信消息包含所述目标函数的函数执行结果的情况下,向所述第一窗口发送所述函数执行结果;或,在所述第二通信消息不包含所述函数执行结果的情况下,向所述第一窗口发送提示信息;其中,所述提示信息用于表征所述第二窗口未查找到所述目标函数。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122534281A_ABST
    Figure CN122534281A_ABST
Patent Text Reader

Abstract

The application relates to a function calling method and a terminal. The method comprises the following steps: intercepting a cross-domain calling request of a first window; the first window and a second window are integrated in the same browser, and the domain names of the first window and the second window are different; based on the cross-domain calling request, a first communication message is generated, and the first communication message is sent to the second window through a cross-domain communication interface between the first window and the second window; after receiving a second communication message sent by the second window through the cross-domain communication interface, if the second communication message contains a function execution result of a target function, the function execution result is sent to the first window; or if the second communication message does not contain the function execution result, prompt information is sent to the first window; wherein the prompt information is used to indicate that the second window has not found the target function. The function calling method can improve the development efficiency of the cross-domain function calling function.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a function call method and terminal. Background Technology

[0002] With the popularization of micro-frontends, modular development, and multi-window collaborative applications, cross-domain window communication has become a core requirement for World Wide Web (Web) applications.

[0003] Currently, due to the browser's Same-Origin Policy, webpage windows with different domains, protocols, or ports cannot directly call each other's functions. Cross-domain windows mainly achieve function calls by sending cross-domain communication messages to each other's windows.

[0004] However, since the cross-domain communication interface only provides basic message passing capabilities, developers need to manually implement a complete message subscription / publishing mechanism to achieve cross-domain function calls. For different function call scenarios, they need to repeatedly write boilerplate code such as message subscription, type judgment, and parameter encapsulation, which results in low development efficiency. Summary of the Invention

[0005] This application provides a function calling method and terminal, which can improve the development efficiency of cross-domain function calling functionality.

[0006] Firstly, some embodiments provide a function call method, including:

[0007] Intercept cross-domain call requests from the first window; wherein the cross-domain call request is used to request a call to a target function in the second window; the first window and the second window are integrated in the same browser, and the domain names of the first window and the second window are different;

[0008] Based on the cross-domain call request, a first communication message is generated, and the first communication message is sent to the second window through the cross-domain communication interface between the first window and the second window; wherein, the first communication message is used to instruct the second window to execute the target function;

[0009] Upon receiving the second communication message sent by the second window through the cross-domain communication interface, if the second communication message contains the function execution result of the target function, the function execution result is sent to the first window; or,

[0010] If the second communication message does not contain the function execution result, a prompt message is sent to the first window; wherein the prompt message is used to indicate that the second window has not found the target function.

[0011] The above technical solution intercepts cross-domain communication requests from the first window, triggers a proxy mechanism, automatically generates and sends a first communication message based on the cross-domain call request, and returns data to the first window based on different received second communication messages, thus realizing cross-domain function calls between the first and second windows. The developer of the first window does not need to be aware of the underlying communication details to implement cross-domain function calls; they only need to use existing function call knowledge, reducing cognitive burden and eliminating the need to repeatedly write boilerplate code for different communication scenarios, effectively improving development efficiency and reducing code redundancy. The proxy mechanism separates the logic of the function caller and the function callee; the function caller only needs to use the proxy interface to implement cross-domain function calls, and both parties only need to focus on their own business implementation, ensuring the accuracy of the business implementation.

[0012] In some embodiments, the method further includes:

[0013] Based on the call identifier contained in the second communication message, find the callback function corresponding to the different states of the Promise object associated with the call identifier;

[0014] The different states of the Promise object include a success state; the step of sending the function execution result to the first window when the second communication message contains the function execution result of the target function includes:

[0015] If the second communication message contains the function execution result of the target function, the callback function corresponding to the success state of the Promise object is invoked to send the function execution result to the first window.

[0016] In the above embodiments, the callback functions corresponding to different states of the Promise object are found based on the call identifier contained in the second communication message. When the second communication message contains a function-specified result, the function execution result can be automatically sent to the first window without requiring the developer to write a message response mechanism, thereby improving code development efficiency and reducing code complexity.

[0017] In some embodiments, the different states of the Promise object also include a failure state; the step of sending a prompt message to the first window when the second communication message does not contain the function execution result includes:

[0018] If the second communication message does not contain the result of the function execution, the callback function corresponding to the failure state of the Promise object is invoked to send a prompt message to the first window.

[0019] In the above embodiments, when the second communication message does not contain the result specified by the function, a prompt is automatically sent to the first window, eliminating the need for developers to write response mechanisms for abnormal situations, thereby improving code development efficiency and reducing code complexity.

[0020] In some embodiments, the different states of the Promise object also include a timeout state; the method further includes:

[0021] If the second communication message is not received within a preset time, the callback function corresponding to the timeout state of the Promise object is invoked to send a timeout message to the first window.

[0022] In the above embodiments, if the second communication message is not received within a preset time, the corresponding callback function is automatically invoked to prompt the first window that the call has timed out. This eliminates the need for developers to write response mechanisms for abnormal situations, thereby improving code development efficiency and reducing code complexity.

[0023] In some embodiments, the cross-domain call request includes a call identifier; the method further includes:

[0024] Create a Promise object; and,

[0025] Establish an association between the call identifier and the callback functions corresponding to different states of the Promise object, and store the association.

[0026] In the above embodiments, the association between the call identifier contained in the cross-domain call request and the callback function corresponding to different states of the Promise object is stored in advance. The first window can be automatically responded to based on whether the second communication message is received and the content contained in the second communication message. Developers do not need to write response mechanisms for different situations. Asynchronous results can be obtained directly. Different projects can reuse the code directly, reducing the amount of repetitive development work, improving code development efficiency, and reducing code complexity.

[0027] In some embodiments, the method further includes:

[0028] Once a callback function corresponding to any state of the Promise object is detected to be invoked, the stored association between the invocation identifier and the callback functions corresponding to different states of the Promise object is cleared.

[0029] In the above embodiments, after detecting that a callback function has been called, the association between the stored call identifier and the callback function is cleared, which can release resources in a timely manner and improve resource utilization.

[0030] In some embodiments, the cross-domain call request includes a call identifier and call information for the target function;

[0031] The step of generating a first communication message based on the cross-domain call request includes:

[0032] The call identifier and the call information are encapsulated according to a specified message format to obtain a first communication message.

[0033] In the above embodiments, the call identifier and call information are encapsulated to generate a first communication message, which automatically converts the cross-domain call request into a standard communication format. Developers do not need to be aware of the underlying communication details to realize cross-domain function calls.

[0034] In some embodiments, the first communication message includes call information of the target function; the first communication message is used to instruct the second window to execute the target function and return a second communication message containing the function execution result if the target function is found according to the call information, or to return a second communication message without the function execution result if the target function is not found according to the call information.

[0035] In the above embodiments, the call information of the target function is provided through the first communication message, and the second window processes the function call according to the call information, thereby realizing the logical separation between the function caller and the function callee. The function caller can realize cross-domain function calls only through the proxy interface, and both parties only need to focus on their own business implementation, ensuring the accuracy of business implementation.

[0036] Secondly, some embodiments also provide a terminal, including:

[0037] Displays and controllers;

[0038] The controller is configured to:

[0039] Perform the following operations on the proxy instance in the second window through the first window:

[0040] Intercept cross-domain call requests from the first window; wherein the cross-domain call request is used to request a call to a target function in the second window; the first window and the second window are integrated in the same browser, and the domain names of the first window and the second window are different;

[0041] Based on the cross-domain call request, a first communication message is generated, and the first communication message is sent to the second window through the cross-domain communication interface between the first window and the second window; wherein, the first communication message is used to instruct the second window to execute the target function;

[0042] Upon receiving the second communication message sent by the second window through the cross-domain communication interface, if the second communication message contains the function execution result of the target function, the function execution result is sent to the first window; or,

[0043] If the second communication message does not contain the function execution result, a prompt message is sent to the first window; wherein the prompt message is used to indicate that the second window has not found the target function.

[0044] The above technical solution intercepts cross-domain communication requests from the first window, triggers a proxy mechanism, automatically generates and sends a first communication message based on the cross-domain call request, and returns data to the first window based on different received second communication messages, thus realizing cross-domain function calls between the first and second windows. The developer of the first window does not need to be aware of the underlying communication details to implement cross-domain function calls; they only need to use existing function call knowledge, reducing cognitive burden and eliminating the need to repeatedly write boilerplate code for different communication scenarios, effectively improving development efficiency and reducing code redundancy. The proxy mechanism separates the logic of the function caller and the function callee; the function caller only needs to use the proxy interface to implement cross-domain function calls, and both parties only need to focus on their own business implementation, ensuring the accuracy of the business implementation.

[0045] In some embodiments, the controller is further configured to:

[0046] If the second window is detected to have finished loading, a proxy instance of the first window is created for the second window.

[0047] Thirdly, some embodiments also provide a function calling device configured in a terminal, including:

[0048] An interception module is used to intercept cross-domain call requests from the first window; wherein the cross-domain call request is used to request to call a target function in the second window; the first window and the second window are integrated in the same browser, and the domain names of the first window and the second window are different;

[0049] The generation module is configured to generate a first communication message based on the cross-domain call request, and send the first communication message to the second window through the cross-domain communication interface between the first window and the second window; wherein, the first communication message is used to instruct the second window to execute the target function;

[0050] The receiving module is configured to, upon receiving a second communication message sent by the second window through the cross-domain communication interface, send the function execution result to the first window if the second communication message contains the function execution result of the target function; or, if the second communication message does not contain the function execution result, send a prompt message to the first window; wherein the prompt message is used to indicate that the second window has not found the target function.

[0051] The above technical solution intercepts cross-domain communication requests from the first window, triggers a proxy mechanism, automatically generates and sends a first communication message based on the cross-domain call request, and returns data to the first window based on different received second communication messages, thus realizing cross-domain function calls between the first and second windows. The developer of the first window does not need to be aware of the underlying communication details to implement cross-domain function calls; they only need to use existing function call knowledge, reducing cognitive burden and eliminating the need to repeatedly write boilerplate code for different communication scenarios, effectively improving development efficiency and reducing code redundancy. The proxy mechanism separates the logic of the function caller and the function callee; the function caller only needs to use the proxy interface to implement cross-domain function calls, and both parties only need to focus on their own business implementation, ensuring the accuracy of the business implementation.

[0052] Fourthly, a computer-readable storage medium is provided, which stores a computer program that, when executed by a function calling device, causes the function calling device to perform any of the function calling methods described in the first aspect.

[0053] Fifthly, a computer program product is provided, comprising: a computer program that, when executed by a function calling device, causes the function calling device to perform any of the function calling methods described in the first aspect. Attached Figure Description

[0054] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0055] Figure 1 This is a schematic diagram illustrating an operational scenario between a display device and a control device provided in some embodiments of this application;

[0056] Figure 2 This is a schematic diagram of the hardware configuration of a display device provided in some embodiments of this application;

[0057] Figure 3 This is a schematic diagram of the hardware configuration of the control device provided in some embodiments of this application;

[0058] Figure 4 This is a schematic diagram of the software configuration of a display device provided in some embodiments of this application;

[0059] Figure 5 A flowchart illustrating the function call method provided in some embodiments of this application;

[0060] Figure 6 A flowchart illustrating a function execution method provided in some embodiments of this application;

[0061] Figure 7 A flowchart illustrating the association relationship storage method provided in some embodiments of this application;

[0062] Figure 8 A flowchart illustrating a message response method provided in some embodiments of this application;

[0063] Figure 9 A schematic diagram illustrating function call methods provided in other embodiments of this application;

[0064] Figure 10 A flowchart illustrating a function call method provided in some embodiments of this application;

[0065] Figure 11 This application provides schematic diagrams illustrating function calls between devices during the function call process in some embodiments.

[0066] Figure 12 This is a block diagram of the function calling device in some embodiments. Detailed Implementation

[0067] The embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described below do not represent all embodiments consistent with this application. They are merely examples of systems and methods consistent with some aspects of this application as detailed in the claims.

[0068] It should be noted that the brief descriptions of terms in this application are only for the convenience of understanding the embodiments described below, and are not intended to limit the embodiments of this application. Unless otherwise stated, these terms should be understood in their ordinary and common meaning.

[0069] The terms "first," "second," "third," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar or related objects or entities, and do not necessarily imply a specific order or sequence, unless otherwise specified. It should be understood that such terms are interchangeable where appropriate.

[0070] The terms “comprising” and “having”, and any variations thereof, are intended to cover but not exclude inclusion, for example, a product or device that includes a range of components is not necessarily limited to all of the components that are clearly listed, but may include other components that are not clearly listed or that are inherent to such product or device.

[0071] The term "module" refers to any known or subsequently developed hardware, software, firmware, artificial intelligence, fuzzy logic, or combination of hardware and / or software code that is capable of performing the functions associated with that element.

[0072] In some embodiments, the function call method in this application can be applied to a terminal, wherein a browser can be installed on the terminal, and the first window and the second window can be web page windows in the browser.

[0073] In some embodiments, the terminal may be a display device 200, which generally refers to a device with screen display and data processing capabilities. For example, display devices 200 include, but are not limited to, smart TVs, mobile terminals, computers, monitors, advertising screens, wearable devices, virtual reality devices, augmented reality devices, etc.

[0074] Figure 1 This is a schematic diagram illustrating an operational scenario between a display device and a control device provided in some embodiments of this application. For example... Figure 1 As shown, users can operate the display device 200 via touch operation, mobile terminal 300, and control device 100. For example, control device 100 can be a remote control, stylus, gamepad, etc.

[0075] The mobile terminal 300 can function as a control device for human-computer interaction between the user and the display device 200. It can also function as a communication device for establishing a communication connection with the display device 200 and exchanging data. In some embodiments, the mobile terminal 300 can have software applications installed on it and communicate with the display device 200 via network communication protocols to achieve one-to-one control and data communication. Furthermore, it can transmit audio and video content displayed on the mobile terminal 300 to the display device 200 for synchronized display.

[0076] like Figure 1The diagram also shows that the display device 200 communicates with the server 400 via various communication methods. This allows the display device 200 to communicate via a local area network (LAN), a wireless local area network (WLAN), and other networks.

[0077] Display device 200 can provide broadcast television reception function, and can also be equipped with intelligent network television function that provides computer support, including but not limited to network television, smart television, Internet Protocol Television (IPTV), etc.

[0078] Figure 2 Provided for some embodiments of this application Figure 1 Hardware configuration block diagram of display device 200.

[0079] In some embodiments, the display device 200 may include at least one of a tuner 210, a communication device 220, a detector 230, a device interface 240, a controller 250, a display 260, an audio output device 270, a memory, a power supply, and a user input interface.

[0080] In some embodiments, detector 230 is used to acquire signals from the external environment or to interact with the outside world. For example, detector 230 includes a light receiver, a sensor for acquiring ambient light intensity; or, detector 230 includes an image acquisition device, such as a camera, which can be used to acquire external environmental scenes, user attributes, or user interaction gestures; or, detector 230 includes a sound acquisition device, such as a microphone, for receiving external sounds.

[0081] In some embodiments, the display 260 includes display function components for presenting images and driving components for driving image display. The display 260 is used to receive and display image signals output from the controller 250. For example, the display 260 can be used to display video content, image content, menu control interface components, and user control UI interfaces, etc.

[0082] In some embodiments, the communication device 220 is a component used to communicate with external devices or the server 400 according to various communication protocol types. The display device 200 may have multiple communication devices 220 depending on the supported communication methods. For example, when the display device 200 supports wireless network communication, it may have a communication device 220 that includes the international wireless Fidelity (WiFi) standard. When the display device 200 supports Bluetooth connectivity, it needs to have a communication device 220 that includes Bluetooth functionality.

[0083] The communication device 220 enables the display device 200 to communicate with external devices or the server 400 via wireless or wired connections. Wired connections utilize data cables, interfaces, or other components to connect the display device 200 to external devices. Wireless connections utilize wireless signals or wireless networks. The display device 200 can directly establish a connection with external devices or indirectly through gateways, routers, or other connection devices.

[0084] In some embodiments, the controller 250 may include at least one of a central processing unit, a video processor, an audio processor, a graphics processor, and a power processor, and a first to an nth interface for input / output. The controller 250 controls the operation of the display device and responds to user operations through various software control programs stored in memory. The controller 250 controls the overall operation of the display device 200.

[0085] In some embodiments, the controller 250 and the tuner 210 may be located in different separate devices, that is, the tuner 210 may also be located in an external device of the main device where the controller 250 is located, such as an external set-top box.

[0086] In some embodiments, a user can input user commands through a graphical user interface (GUI) displayed on a display 260, and the user input interface receives user input commands through the graphical user interface (GUI).

[0087] In some embodiments, the audio output device 270 can be a built-in speaker of the display device 200 or an external audio output device connected to the display device 200. For the external audio output device connected to the display device 200, the display device 200 may also be provided with an external audio output terminal, through which the audio output device can be connected to the display device 200 to output sound from the display device 200.

[0088] In some embodiments, the user input interface 280 can be used to receive instructions from user input.

[0089] Figure 3 Provided for some embodiments of this application Figure 1 Hardware configuration block diagram of the central control device. (Example) Figure 3 As shown, the control device 100 may include: a controller 110, a communication interface 130, a user input / output interface, a memory, and a power supply.

[0090] The control device 100 is configured to control the display device 200, and to receive user input operation commands and convert the operation commands into commands that the display device 200 can recognize and respond to, thus acting as an intermediary for interaction between the user and the display device 200.

[0091] In some embodiments, the control device 100 may be an intelligent device. For example, the control device 100 may be equipped with various applications for controlling the display device 200 according to user needs.

[0092] In some embodiments, such as Figure 1 As shown, the mobile terminal 300 or other smart electronic devices can perform similar functions to the control device 100 after installing the application of the control display device 200.

[0093] The controller 110 includes a processor 112, RAM 113, ROM 114, a communication interface 130, and a communication bus. The controller 110 is used to control the operation of the control device 100, as well as the communication and cooperation between internal components and the external and internal data processing functions.

[0094] Under the control of the controller 110, the communication interface 130 enables communication of control signals and data signals with the display device 200. The communication interface 130 may include at least one of other near-field communication modules such as WiFi chip 131, Bluetooth module 132, and NFC module 133.

[0095] User input / output interface 140, wherein the input interface includes at least one of other input interfaces such as microphone 141, touchpad 142, sensor 143, and button 144.

[0096] In some embodiments, the control device 100 includes at least one of a communication interface 130 and an input / output interface 140. The control device 100 is configured with the communication interface 130, such as a WiFi, Bluetooth, or NFC module, which can encode user input commands via WiFi, Bluetooth, or NFC protocols and send them to the display device 200.

[0097] The memory 190 is used to store various operating programs, data, and applications for driving and controlling the control device 100 under the control of the controller. The memory 190 can also store various control signal instructions input by the user.

[0098] The power supply 180 is used to provide operating power support for the various components of the control device 100 under the control of the controller.

[0099] In some embodiments, the display device 200 may run an operating system to enable user interaction. An operating system is a computer program that manages and controls the hardware and software resources of the display device 200. The operating system can (control the display device) provide a user interface, allowing users to interact with the display device 200 and supporting the running of various applications.

[0100] It should be noted that the operating system can be a native operating system based on a specific operating platform, a third-party operating system that is deeply customized based on a specific operating platform, or an independent operating system specifically developed for display devices.

[0101] An operating system can be divided into different modules or levels based on the functions it implements, for example... Figure 4 As shown, in some embodiments, the system is divided into four layers, from top to bottom: the Applications layer (referred to as the "Application Layer"), the Application Framework layer (referred to as the "Framework Layer"), the System Library layer, and the Kernel layer.

[0102] In some embodiments, the application layer provides services and interfaces for applications, enabling the display device 200 to run applications and interact with the user based on the applications. The application layer may contain at least one application, which may be a built-in Windows program, system settings program, or clock program of the operating system; or it may be an application developed by a third-party developer. In specific implementations, the application packages in the application layer are not limited to the examples above.

[0103] The framework layer provides application programming interfaces (APIs) and a programming framework for applications. The application framework layer includes predefined functions. It acts as a central processing unit, determining the actions taken by applications within the application layer. Through the API, applications can access system resources and obtain system services during execution.

[0104] like Figure 4As shown, the application framework layer in this embodiment includes a view system, managers, and content providers. The view system designs and implements the application's interface and interactions, and includes lists, grids, text boxes, and buttons. The managers include at least one of the following modules: an activity manager for interacting with all running activities in the system; a location manager for providing system services or applications with access to system location services; a package manager for retrieving various information related to application packages currently installed on the device; a notification manager for controlling the display and clearing of notification messages; and a window manager for managing icons, windows, toolbars, wallpapers, and desktop widgets on the user interface.

[0105] In some embodiments, the Activity Manager manages the lifecycle of individual applications and common navigation and back functions, such as controlling application exit, opening, and back actions. The Window Manager manages all window programs, such as obtaining the screen size, determining if a status bar is present, locking the screen, capturing the screen, and controlling changes to the display window, such as shrinking the display window, shaking the display, or distorting the display.

[0106] In some embodiments, the system runtime library layer can provide support for the framework layer. When the framework layer is used, the operating system runs the instruction library contained in the system runtime library layer, such as the C / C++ instruction library, to implement the functions to be performed by the framework layer.

[0107] In some embodiments, the kernel layer is a functional layer situated between the hardware and software of the display device 200. The kernel layer can implement functions such as hardware abstraction, multitasking, and memory management. For example, ... Figure 4 As shown, hardware drivers can be configured in the kernel layer. The kernel layer can contain at least one of the following drivers: audio driver, display driver, Bluetooth driver, camera driver, WIFI driver, USB driver, HDMI driver, sensor driver (such as fingerprint sensor, temperature sensor, pressure sensor, etc.), and power driver, etc.

[0108] It should be noted that the above examples are merely a simple division of operating system functions and do not limit the specific form of the operating system of the display device 200 in this application embodiment. Depending on the function of the display device, the type of operating system, and other factors, the number of levels and the specific level type of the operating system may be expressed in other forms.

[0109] With the widespread adoption of micro-frontends, modular development, and multi-window collaborative applications, cross-domain window communication has become a core requirement for web applications. Currently, due to browser same-origin policies, webpage windows from different domains, protocols, or ports cannot directly call each other's functions. Cross-domain window communication primarily achieves function calls by sending cross-domain communication messages to each other's windows. However, since cross-domain communication interfaces only provide basic message passing capabilities, developers need to manually implement a complete message subscription / publishing mechanism to achieve cross-domain function calls. For different function call scenarios, they need to repeatedly write boilerplate code such as message subscription, type checking, and parameter encapsulation, resulting in low development efficiency.

[0110] Based on this, in some embodiments, a function call method is provided. This function call method can be implemented by a terminal, which includes a display and a controller.

[0111] In one alternative implementation, taking the function call method applied to the controller in the terminal as an example, when the second window is detected to have finished loading, a proxy instance of the first window for the second window is created.

[0112] In this context, the first and second windows are integrated within the same browser, and their domain names are different. Windows can also be referred to as web pages, without further specific limitations. Specifically, the first and second windows can be browser window pairs with relationships such as containment, referencing, sibling, or hierarchical relationships. For example, the first window can be the parent window, and the second window can be an inline frame (iframe) window of the first window, or a window opened by the first window using the "window.open" method, etc., without further specific limitations.

[0113] Understandably, to reduce the workload for developers implementing cross-domain function calls, this application proposes executing the function call methods of this application through a proxy instance of the first window for the second window. Therefore, upon detecting that the second window has finished loading, a proxy instance of the first window for the second window is created. Optionally, an instance creation function is defined to monitor the onload event of the second window, and upon detecting the onload event, the instance creation function is triggered to create the proxy instance of the first window for the second window. Optionally, during the creation of the proxy instance, a call identifier is specified for method calls between the first and second windows. The call identifier is used to identify method calls between the first and second windows. It is understood that for the first window, there may be multiple second windows that are related to it. Therefore, during the creation of the proxy instance, different call identifiers need to be assigned to different second windows to distinguish function calls between the first window and different second windows. Furthermore, this can be encapsulated into a proxy interface, which window developers can use to complete proxy instantiation and function calls.

[0114] In one embodiment, a secure handshake is initiated to the second window through a proxy instance. After the second window verifies the identity / confirms the status, a handshake success is returned, completing the proxy instantiation. The first window can then make function calls through the proxy instance.

[0115] Based on the above embodiments, taking the application of function call methods to a proxy instance as an example, such as... Figure 5 As shown, the specific steps include:

[0116] S501 intercepts cross-domain call requests from the first window.

[0117] The cross-domain call request is used to request the invocation of the target function in the second window. Optionally, the first window can trigger a cross-domain call request using "proxyObj.method(args)", where the target function to be called can be entered in the "method" field, and the parameters of the target function can be entered in the "args" field. In this way, the developers of the first window do not need to understand the underlying cross-domain communication details; they only need to use their existing knowledge of function calls to complete the cross-domain function call.

[0118] S502, based on the cross-domain call request, generate a first communication message, and send the first communication message to the second window through the cross-domain communication interface between the first window and the second window.

[0119] Understandably, after intercepting a cross-domain call request, in order to call the function in the second window, the cross-domain call request needs to be converted into a communication message adapted to the cross-domain communication interface, namely the first communication message. The first communication message is used to instruct the second window to execute the target function. The cross-domain communication interface can be based on "window.postMessage," which allows one window to asynchronously send data messages to another window with a reference relationship. The message receiver obtains the message content by listening to message events, thus completing the data interaction. Alternatively, the cross-domain communication interface can be based on "BroadcastChannel." However, since the message broadcasting method of "BroadcastChannel" affects all "BroadcastChannels" under a specific broadcast channel, currently, the most reasonable method for one-to-one communication between cross-domain windows is based on "window.postMessage." Therefore, the cross-domain communication interface in this embodiment is based on "window.postMessage."

[0120] Optionally, after receiving the first communication message, the second window executes the target function and obtains the function execution result. Understandably, the second window also needs to encapsulate the function execution result into a communication message adapted to the cross-domain communication interface (referred to as the second communication message), and then send the second communication message to the first window through the cross-domain communication interface.

[0121] In the above embodiments, by applying the concept of transparent proxy to cross-domain communication, a truly localized calling experience can be achieved. At the business developer's contact layer (i.e., the application layer), a cross-domain call request can be triggered simply by business code such as "proxyObj.method(args)". At the proxy layer, the cross-domain call request is intercepted and automatically encapsulated into a first communication message. At the communication layer, the first communication message is sent through the cross-domain communication interface. Since developers do not need to contact the communication layer, they do not need to learn a new communication interface I. They can achieve cross-domain communication using their existing function call knowledge. Compared with traditional solutions that require understanding concepts such as postMessage, message format, and event listening, this can reduce the cognitive burden by more than 70%.

[0122] S503: After receiving the second communication message sent by the second window through the cross-domain communication interface, if the second communication message contains the function execution result of the target function, send the function execution result to the first window; or, if the second communication message does not contain the function execution result, send a prompt message to the first window.

[0123] Understandably, although the first window requests the target function through a cross-domain call request, the target function may not be found in the second window. In other words, if the second window can find the target function and execute it to obtain the function execution result, then the second communication message contains the function execution result of the target function. At this time, sending the function execution result to the first window completes the entire function call process. If the second window fails to find the target function, it will also return a second communication message that does not contain the function execution result. In this case, a prompt message needs to be sent to the first window to indicate that the second window has not found the target function.

[0124] The above technical solution intercepts cross-domain communication requests from the first window, triggers a proxy mechanism, automatically generates and sends a first communication message based on the cross-domain call request, and returns data to the first window based on different received second communication messages, thus realizing cross-domain function calls between the first and second windows. The developer of the first window does not need to be aware of the underlying communication details to implement cross-domain function calls; they only need to use existing function call knowledge, reducing cognitive burden and eliminating the need to repeatedly write boilerplate code for different communication scenarios, effectively improving development efficiency and reducing code redundancy. The proxy mechanism separates the logic of the function caller and the function callee; the function caller only needs to use the proxy interface to implement cross-domain function calls, and both parties only need to focus on their own business implementation, ensuring the accuracy of the business implementation.

[0125] In some embodiments, the first communication message contains call information of the target function; the first communication message is used to instruct the second window to execute the target function and return a second communication message containing the function execution result if the target function is found according to the call information, or to return a second communication message without the function execution result if the target function is not found according to the call information.

[0126] The call information for the target function indicates how to invoke it. Optionally, the call information may include the function identifier and parameters of the target function. The function identifier is used to locate the target function; for example, the function identifier could be the name of the target function. The parameters are used to execute the target function. During execution, the parameters are input into the target function, and a return value, i.e., the function execution result, is obtained. Furthermore, if the target function is found based on the call information, the second window can return a second communication message containing the function execution result. If the target function is not found based on the call information, the second window can return a second communication message without containing the function execution result.

[0127] In the above embodiments, the call information of the target function is provided through the first communication message, and the second window processes the function call according to the call information, thereby realizing the logical separation between the function caller and the function callee. The function caller can realize cross-domain function calls only through the proxy interface, and both parties only need to focus on their own business implementation, ensuring the accuracy of business implementation.

[0128] In some embodiments, the cross-domain call request includes a call identifier and call information of the target function; the step of generating the first communication message in S502 is further refined, including:

[0129] The call identifier and call information are encapsulated according to the specified message format to obtain the first communication message.

[0130] The call identifier is used to uniquely identify the function call between the first window and the second window. The specified message format is a message format that adapts to the communication rules of the cross-domain communication interface. The call identifier and call information are encapsulated according to the specified message format. The resulting first communication message contains the call identifier and call information and can be sent through the cross-domain communication interface.

[0131] Optionally, after constructing the first communication message, to ensure communication security, the first communication message is encrypted to obtain a first encrypted message, and the first encrypted message is signed to obtain a first signed message. The first signed message is then sent to the second window through the cross-domain communication interface. Subsequently, upon receiving the first signed message, the second window may, as follows: Figure 6 As shown, the processing is carried out in the following ways, including:

[0132] S601, perform integrity verification on the first signed message and obtain the verification result.

[0133] S602, if the verification result indicates that the verification is successful, the first signature message is decrypted to obtain the first communication message.

[0134] S603: Based on the call information contained in the first communication message, search for the target function from the registered function category, and if the target function is found, execute the target function to obtain the function execution result.

[0135] S604 encapsulates the function execution result according to the specified message format to obtain the second communication message.

[0136] Optionally, the second communication message can be encrypted and signed before being sent to the first window via the cross-domain communication interface.

[0137] In the above embodiments, the call identifier and call information are encapsulated to generate a first communication message, which automatically converts the cross-domain call request into a standard communication format. Developers do not need to be aware of the underlying communication details to realize cross-domain function calls.

[0138] In some embodiments, the cross-domain call request includes a call identifier, such as... Figure 7 As shown, a relational storage method is proposed, including:

[0139] S701, Create a Promise object.

[0140] The Promise object is used to handle asynchronous operations. Optionally, the Promise object can have different states, and each state is associated with a corresponding callback function. In this way, after the first communication message is sent to the second window, the callback function corresponding to the different states of the Promise object can be triggered according to different responses, so as to realize automated message response.

[0141] S702, establish the association between the call identifier and the callback function corresponding to different states of the Promise object, and store the association.

[0142] It is understandable that, since the call identifier is used to represent the function call between the first window and the second window, the main purpose of establishing the association between the call identifier and the callback functions corresponding to different states of the Promise object is to specifically handle the message response between the first window and the second window through these callback functions. Therefore, the association is stored so that the callback function can be found according to the call identifier and the message response can be implemented through the callback function.

[0143] In the above embodiments, the association between the call identifier contained in the cross-domain call request and the callback function corresponding to different states of the Promise object is stored in advance. The first window can be automatically responded to based on whether the second communication message is received and the content contained in the second communication message. Developers do not need to write response mechanisms for different situations. Asynchronous results can be obtained directly. Different projects can reuse the code directly, reducing the amount of repetitive development work, improving code development efficiency, and reducing code complexity.

[0144] In some embodiments, such as Figure 8 As shown, a message response method is proposed, including:

[0145] S801, based on the call identifier contained in the second communication message, find the callback function corresponding to different states of the Promise object associated with the call identifier.

[0146] The first communication message contains a call identifier. The second window, during the construction of the second communication message, also needs to include the call identifier so that the proxy instance, upon receiving the second communication message, can locate the corresponding callback function based on the call identifier. For example, call identifier 11 is associated with callback functions corresponding to different states of Promise object 1, call identifier 12 is associated with callback functions corresponding to different states of Promise object 2, and call identifier 13 is associated with callback functions corresponding to different states of Promise object 3. If the second communication message contains call identifier 12, then the callback functions corresponding to different states of Promise object 2 associated with call identifier "12" will be found.

[0147] Optionally, the different states of a Promise object include a success state, also known as a resolve state; therefore, the step of sending the function execution result to the first window can be implemented as follows:

[0148] S802, if the second communication message contains the function execution result of the target function, call the callback function corresponding to the success state of the Promise object and send the function execution result to the first window.

[0149] It is understandable that if the second communication message contains the function execution result of the target function, it indicates that the task of the function call was successfully executed and the function execution result was obtained. Therefore, the callback function corresponding to the success state of the Promise object is triggered, and the function execution result is returned to the first window.

[0150] In the above embodiments, the callback functions corresponding to different states of the Promise object are found based on the call identifier contained in the second communication message. When the second communication message contains a function-specified result, the function execution result can be automatically sent to the first window without requiring the developer to write a message response mechanism, thereby improving code development efficiency and reducing code complexity.

[0151] Optionally, different message types can be set for second communication messages containing different content. This allows for quick determination of the specific content of the second communication message based on its message type. For example, a second communication message containing a function execution result can have a message type of "messageResponse," while a second communication message without a function execution result can have a message type of "methodNotFound," indicating that the target function was not found. Optionally, the first communication message can also have a corresponding message type, which instructs the second window to execute the target function. Based on this, a communication message (first or second communication message) can consist of a message identifier, a call identifier, a message type, and data. Different communication messages have different message identifiers. The first communication message contains call information, while the second communication message contains the function execution result. It should be noted that the message structures listed above are only illustrative examples; specific settings can be implemented according to actual needs, and no specific limitations are imposed here.

[0152] In some embodiments, the different states of a Promise object also include a failure state, also known as a rejected state; the step of sending a prompt message to the first window is further defined, including:

[0153] If the second communication message does not contain the result of the function execution, the callback function corresponding to the failure status of the Promise object is called to send a prompt message to the first window.

[0154] In the case where the second communication message does not contain the function execution result, it indicates that the task execution of the function call has failed. Therefore, the callback function corresponding to the failure state of the Promise object is triggered, and a prompt message is sent to the first window to indicate that the target function cannot be found. In this way, after receiving the prompt message, the first window can check whether it should communicate with other second windows across domains to call the target function, and whether there are any errors in the call information of the target function provided, so as to correctly call the target function through subsequent cross-domain call requests.

[0155] In the above embodiments, when the second communication message does not contain the result specified by the function, a prompt is automatically sent to the first window, eliminating the need for developers to write response mechanisms for abnormal situations, thereby improving code development efficiency and reducing code complexity.

[0156] In some embodiments, the different states of a Promise object also include a timeout state. A timeout handling method is proposed, including:

[0157] If no second communication message is received within the preset time, the callback function corresponding to the timeout state of the Promise object is invoked to send a timeout message to the first window.

[0158] The preset time can be set based on experience, multiple trials, and actual needs. It is understandable that if the second communication message is not received within the preset time, it indicates that an abnormal situation may have occurred during the cross-domain function call. It is also understandable that in the face of an abnormal situation, one should not wait indefinitely, as this would cause system resource consumption. Therefore, the callback function corresponding to the timeout state of the Promise object is triggered to send a call timeout message to the first window. The timeout state can also be considered a Reject state. Sending a call timeout message to the first window is used to indicate that the first window has not received the second communication message within the preset time. In this way, the first window can decide whether to re-initiate the cross-domain call request.

[0159] In the above embodiments, if no second communication message is received within a preset time, the corresponding callback function is automatically invoked to prompt the first window that the call has timed out. This eliminates the need for developers to write response mechanisms for abnormal situations, thereby improving code development efficiency and reducing code complexity.

[0160] In some embodiments, a resource cleanup method is provided, comprising:

[0161] Once a callback function corresponding to any state of a Promise object is detected to be invoked, the stored association between the invocation identifier and the callback function corresponding to different states of the Promise object is cleared.

[0162] Understandably, once the callback function corresponding to any state of the Promise object is called, whether the Promise object is in a successful or failed state, it means that the cross-domain call request has already had a corresponding execution result. Therefore, the storage association can be cleared, storage resources can be released, and resource utilization can be improved.

[0163] In the above embodiments, after detecting that a callback function has been called, the association between the stored call identifier and the callback function is cleared, which can release resources in a timely manner and improve resource utilization.

[0164] Based on the above embodiments, such as Figure 9As shown, the first window triggers a cross-domain call request through business code. The first window intercepts the cross-domain call request for the proxy instance of the second window. The proxy instance creates a Promise object, associates and stores the call identifier with the callback functions corresponding to different states of the Promise object, and encapsulates a first communication message based on the call identifier and call information in the cross-domain call request. This first communication message is sent to the second window through the cross-domain communication interface. The second window parses the first communication message to obtain the call information, locates the target function based on the call information, executes the target function, obtains the function execution result, encapsulates the function execution result into a second communication message, and sends the second communication message to the first window through the cross-domain communication interface. Upon receiving the second communication message, the callback function corresponding to the success state of the Promise object is triggered, and the function execution result is returned to the first window.

[0165] Based on the technical solutions of the above embodiments, an optional embodiment is provided, such as... Figure 10 As shown, the function call method can be implemented as follows:

[0166] S1001 intercepts cross-domain call requests from the first window.

[0167] The cross-domain call request is used to request the invocation of the target function in the second window; the first window and the second window are integrated in the same browser, and the domain names of the first window and the second window are different. The cross-domain call request contains the call identifier and the call information of the target function.

[0168] S1002, create a Promise object; and establish the association between the call identifier and the callback function corresponding to different states of the Promise object, and store the association.

[0169] S1003, the call identifier and call information are encapsulated according to the specified message format to obtain the first communication message.

[0170] The first communication message is used to instruct the second window to execute the target function.

[0171] S1004, the first communication message is sent to the second window through the cross-domain communication interface between the first window and the second window.

[0172] S1005, Receive the second communication message sent by the second window through the cross-domain communication interface.

[0173] S1006, based on the call identifier contained in the second communication message, find the callback function corresponding to the different states of the Promise object associated with the call identifier.

[0174] The different states of a Promise object include a success state and a failure state.

[0175] S1007, if the second communication message contains the function execution result of the target function, call the callback function corresponding to the success state of the Promise object and send the function execution result to the first window; if the second communication message does not contain the function execution result, call the callback function corresponding to the failure state of the Promise object and send a prompt message to the first window.

[0176] The prompt message indicates that the target function was not found in the second window.

[0177] S1008, after detecting that the callback function corresponding to any state of the Promise object has been called, clear the stored association between the call identifier and the callback function corresponding to different states of the Promise object.

[0178] The specific processes of S1001-S1008 described above can be found in the description of the above method embodiments. Their implementation principles and technical effects are similar, and will not be repeated here.

[0179] Based on the technical solutions of the above embodiments, an optional embodiment is provided when the terminal includes a first window, a proxy instance, and a second window. See also Figure 11 The diagram illustrates the function call process between the various parts of the terminal, including:

[0180] S1101, Send cross-domain call request.

[0181] The cross-domain call request is used to request the invocation of the target function in the second window; the first window and the second window are integrated in the same browser, and the domain names of the first window and the second window are different. The cross-domain call request contains the call identifier and the call information of the target function.

[0182] S1102, intercepts the cross-domain call request of the first window.

[0183] S1103, create a Promise object; and establish the association between the call identifier and the callback function corresponding to different states of the Promise object, and store the association.

[0184] S1104, the call identifier and call information are encapsulated according to the specified message format to obtain the first communication message.

[0185] The first communication message is used to instruct the second window to execute the target function.

[0186] S1105, the first communication message is sent to the second window through the cross-domain communication interface between the first window and the second window.

[0187] S1106: Based on the call information contained in the first communication message, locate the target function, and if the target function is found, execute the target function to obtain the function execution result.

[0188] S1107, encapsulate the function execution result according to the specified message format to obtain the second communication message.

[0189] S1108, the second communication message is sent to the proxy instance through the cross-domain communication interface.

[0190] S1109, based on the call identifier contained in the second communication message, find the callback function corresponding to the different states of the Promise object associated with the call identifier.

[0191] S1110, if the second communication message contains the function execution result of the target function, call the callback function corresponding to the success state of the Promise object and send the function execution result to the first window.

[0192] S1111 After detecting that the callback function corresponding to any state of the Promise object has been called, clear the stored association between the call identifier and the callback function corresponding to different states of the Promise object.

[0193] The specific processes of S1101-S1111 described above can be found in the description of the above method embodiments. Their implementation principles and technical effects are similar, and will not be repeated here.

[0194] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0195] Based on the same inventive concept, this application also provides a function calling apparatus for implementing the function calling method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method; therefore, the specific limitations in one or more function calling apparatus embodiments provided below can be found in the limitations of the function calling method described above, and will not be repeated here.

[0196] In one exemplary embodiment, such as Figure 12 As shown, a function call device is provided, configured in a terminal, including: an information receiving module 10, a request sending module 20, and a rights processing module 30, wherein:

[0197] The interception module 1201 is used to intercept cross-domain call requests from the first window; wherein, the cross-domain call request is used to request to call the target function in the second window; the first window and the second window are integrated in the same browser, and the domain names of the first window and the second window are different;

[0198] The generation module 1202 is used to generate a first communication message based on a cross-domain call request, and send the first communication message to the second window through the cross-domain communication interface between the first window and the second window; wherein, the first communication message is used to instruct the second window to execute the target function;

[0199] The receiving module 1203 is configured to, upon receiving a second communication message sent by the second window through the cross-domain communication interface, send the function execution result to the first window if the second communication message contains the function execution result of the target function; or, if the second communication message does not contain the function execution result, send a prompt message to the first window; wherein the prompt message is used to indicate that the second window has not found the target function.

[0200] In some embodiments, the apparatus further includes:

[0201] The lookup module is used to find the callback function corresponding to different states of the Promise object associated with the call identifier based on the call identifier contained in the second communication message;

[0202] The different states of a Promise object include a success state; the receiving module 1203 is specifically used for:

[0203] If the second communication message contains the result of the target function's execution, the callback function corresponding to the success state of the Promise object is invoked to send the function execution result to the first window.

[0204] In some embodiments, the different states of a Promise object also include a failure state; the receiving module 1203 is specifically used for:

[0205] If the second communication message does not contain the result of the function execution, the callback function corresponding to the failure status of the Promise object is called to send a prompt message to the first window.

[0206] In some embodiments, the different states of a Promise object also include a timeout state; the apparatus further includes:

[0207] The calling module is used to call the callback function corresponding to the timeout state of the Promise object and send the call timeout information to the first window if no second communication message is received within a preset time.

[0208] In some embodiments, the cross-domain call request includes a call identifier; the apparatus further includes:

[0209] Create a module for creating Promise objects; and,

[0210] Establish and store the association between the call identifier and the callback function corresponding to different states of the Promise object.

[0211] In some embodiments, the creation module is also used for:

[0212] Once a callback function corresponding to any state of a Promise object is detected to be invoked, the stored association between the invocation identifier and the callback function corresponding to different states of the Promise object is cleared.

[0213] In some embodiments, the cross-domain call request includes a call identifier and call information of the target function; the generation module 1202 is specifically used for:

[0214] The call identifier and call information are encapsulated according to the specified message format to obtain the first communication message.

[0215] In some embodiments, the first communication message contains call information of the target function; the first communication message is used to instruct the second window to execute the target function and return a second communication message containing the function execution result if the target function is found according to the call information, or to return a second communication message without the function execution result if the target function is not found according to the call information.

[0216] The modules in the aforementioned function call device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the computer as software.

[0217] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.

[0218] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.

[0219] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.

[0220] It should be noted that the data involved in this application (including but not limited to account-related data) is all data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.

[0221] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.

[0222] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0223] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A function call method, characterized in that, include: Intercept cross-domain call requests from the first window; wherein the cross-domain call request is used to request a call to a target function in the second window; the first window and the second window are integrated in the same browser, and the domain names of the first window and the second window are different; Based on the cross-domain call request, a first communication message is generated, and the first communication message is sent to the second window through the cross-domain communication interface between the first window and the second window; wherein, the first communication message is used to instruct the second window to execute the target function; Upon receiving the second communication message sent by the second window through the cross-domain communication interface, if the second communication message contains the function execution result of the target function, the function execution result is sent to the first window; or, If the second communication message does not contain the function execution result, a prompt message is sent to the first window; wherein the prompt message is used to indicate that the second window has not found the target function.

2. The method according to claim 1, characterized in that, The method further includes: Based on the call identifier contained in the second communication message, find the callback function corresponding to the different states of the Promise object associated with the call identifier; The different states of the Promise object include a success state; the step of sending the function execution result to the first window when the second communication message contains the function execution result of the target function includes: If the second communication message contains the function execution result of the target function, the callback function corresponding to the success state of the Promise object is invoked to send the function execution result to the first window.

3. The method according to claim 2, characterized in that, The different states of the Promise object also include a failure state; the step of sending a prompt message to the first window when the second communication message does not contain the function execution result includes: If the second communication message does not contain the result of the function execution, the callback function corresponding to the failure state of the Promise object is invoked to send a prompt message to the first window.

4. The method according to claim 2, characterized in that, The different states of the Promise object also include a timeout state; the method also includes: If the second communication message is not received within a preset time, the callback function corresponding to the timeout state of the Promise object is invoked to send a timeout message to the first window.

5. The method according to any one of claims 2-4, characterized in that, The cross-domain call request includes a call identifier; the method further includes: Create a Promise object; and, Establish an association between the call identifier and the callback functions corresponding to different states of the Promise object, and store the association.

6. The method according to any one of claims 2-4, characterized in that, The method further includes: Once a callback function corresponding to any state of the Promise object is detected to be invoked, the stored association between the invocation identifier and the callback functions corresponding to different states of the Promise object is cleared.

7. The method according to any one of claims 1 to 6, characterized in that, The cross-domain call request includes a call identifier and call information for the target function; The step of generating a first communication message based on the cross-domain call request includes: The call identifier and the call information are encapsulated according to a specified message format to obtain a first communication message.

8. The method according to any one of claims 1 to 6, characterized in that, The first communication message contains the call information of the target function; the first communication message is used to instruct the second window to execute the target function and return a second communication message containing the function execution result if the target function is found according to the call information, or to return a second communication message without the function execution result if the target function is not found according to the call information.

9. A terminal, characterized in that, include: Displays and controllers; The controller is configured to: Perform the following operations on the proxy instance in the second window through the first window: Intercept cross-domain call requests from the first window; wherein the cross-domain call request is used to request a call to a target function in the second window; the first window and the second window are integrated in the same browser, and the domain names of the first window and the second window are different; Based on the cross-domain call request, a first communication message is generated, and the first communication message is sent to the second window through the cross-domain communication interface between the first window and the second window; wherein, the first communication message is used to instruct the second window to execute the target function; Upon receiving the second communication message sent by the second window through the cross-domain communication interface, if the second communication message contains the function execution result of the target function, the function execution result is sent to the first window; or, If the second communication message does not contain the function execution result, a prompt message is sent to the first window; wherein the prompt message is used to indicate that the second window has not found the target function.

10. The terminal according to claim 9, characterized in that, The controller is also configured to: If the second window is detected to have finished loading, a proxy instance of the first window is created for the second window.