WO2016177341A1 - Interface calling method and device, and terminal - Google Patents
Interface calling method and device, and terminal Download PDFInfo
- Publication number
- WO2016177341A1 WO2016177341A1 PCT/CN2016/081184 CN2016081184W WO2016177341A1 WO 2016177341 A1 WO2016177341 A1 WO 2016177341A1 CN 2016081184 W CN2016081184 W CN 2016081184W WO 2016177341 A1 WO2016177341 A1 WO 2016177341A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- interface
- target
- browser
- interface function
- browser kernel
- Prior art date
Links
- 238000000034 method Methods 0.000 title claims abstract description 80
- 238000013515 script Methods 0.000 claims abstract description 133
- 230000006870 function Effects 0.000 claims description 295
- 230000008569 process Effects 0.000 claims description 33
- 238000004590 computer program Methods 0.000 claims description 2
- 238000009877 rendering Methods 0.000 description 9
- 238000010586 diagram Methods 0.000 description 8
- VYZAMTAEIAYCRO-UHFFFAOYSA-N Chromium Chemical compound [Cr] VYZAMTAEIAYCRO-UHFFFAOYSA-N 0.000 description 7
- 238000012545 processing Methods 0.000 description 4
- 238000004891 communication Methods 0.000 description 3
- 238000013519 translation Methods 0.000 description 3
- 230000000694 effects Effects 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 239000000463 material Substances 0.000 description 2
- 239000008186 active pharmaceutical agent Substances 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 230000037430 deletion Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000002708 enhancing effect Effects 0.000 description 1
- 239000000835 fiber Substances 0.000 description 1
- 238000001914 filtration Methods 0.000 description 1
- 238000003780 insertion Methods 0.000 description 1
- 230000037431 insertion Effects 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
Definitions
- the present invention relates to the field of computer technologies, and in particular, to an interface calling method, apparatus, and terminal.
- the browser has become one of the necessary application software on the mobile terminal.
- the browser kernel interprets the webpage syntax and renders the webpage.
- the browser kernel provides a large number of interfaces, and the client script can call these interfaces.
- the browser interprets the client scripts loaded in the execution webpage, thereby realizing the dynamic display effect of the webpage and enhancing the interactivity of the webpage.
- the browser includes at least two browser kernels.
- the interface functions provided between different browser kernels may differ.
- different browser kernels have different parameters for the interface functions designed by interface A that implement the same function, and the order of parameters is different, or one browser kernel in the browser provides interface B, and another browser kernel. This interface B is not provided.
- extensions and web pages in existing browsers are developed based on a particular browser kernel, client-side scripts in web pages and extensions are also developed based on that particular browser kernel. Therefore, the client script can run normally on that particular browser kernel.
- the embodiment of the invention provides an interface calling method, device and terminal, which can improve browser compatibility.
- an embodiment of the present invention provides an interface calling method, including:
- the interface call instruction carries an interface identifier and a parameter corresponding to an interface that is required to be loaded by the client script
- the browser kernel currently running in the browser is not the target browser kernel corresponding to the client script
- the first interface function corresponding to the interface identifier provided by the currently running browser kernel and the target browsing Kernel Obtaining a target interface function of the currently running browser kernel corresponding to the preset interface identifier when the second interface function corresponding to the interface identifier is different, and the target interface function is according to the target
- the second interface function provided by the browser kernel performs a preset third interface function corresponding to the currently running browser kernel
- the target interface function is invoked by using the parameter as an input parameter of the target interface function.
- the client script is a script program included in an extension in the browser
- the method further includes:
- the client script corresponding to the extension that needs to be loaded in the browser is inserted into the webpage to be opened.
- the extension further includes a main program loaded in a browser
- the receiving interface calls an instruction, where the interface calling instruction carries an interface identifier and a parameter corresponding to an interface that needs to be invoked by the client script, the method further includes:
- a new process is started to load the main program, and the target browser kernel is loaded in the new process.
- the browser kernel currently running in the browser is not the target browser kernel corresponding to the client script, and the currently running Obtaining, by the browser kernel, a first interface function corresponding to the interface identifier and a second interface function corresponding to the interface identifier provided by the target browser kernel, obtaining a preset corresponding to the interface identifier
- the target interface function of the currently running browser kernel includes:
- the interface identifier is queried from the preset information base according to the interface function of the currently running browser kernel;
- the parameter is used as an input parameter of the target interface function
- the method further includes:
- an embodiment of the present invention provides an interface calling device, where the device is applied to a browser, including:
- a receiving module configured to receive an interface call instruction, where the interface call instruction carries a load client script that needs to be called Interface identifier and parameters corresponding to the interface;
- a determining module configured to: when the currently running browser kernel in the browser is not the target browser kernel corresponding to the client script, and the first interface function corresponding to the interface identifier provided by the currently running browser kernel Obtaining, by the target browser kernel, a second interface function corresponding to the interface identifier, acquiring a target interface function of the currently running browser kernel corresponding to the preset interface identifier, where the target The interface function is a third interface function corresponding to the currently running browser kernel according to the second interface function provided by the target browser kernel;
- the calling module is configured to invoke the parameter as the input parameter of the target interface function, and invoke the target interface function.
- the client script is a script program included in the extension in the browser, and the device further includes:
- the inserting module is configured to insert a client script corresponding to the extension that needs to be loaded in the browser into the webpage to be opened when the triggering event of opening the webpage is detected.
- the extension further includes a main program loaded in a browser, the device further comprising:
- the startup module is configured to start a new process to load the main program when the trigger instruction for loading the extension is received, and the target browser kernel is loaded in the new process.
- the determining module is specifically configured to:
- the interface identifier is queried from the preset information base according to the interface function of the currently running browser kernel;
- the device further includes:
- a return module for returning a result of the call of the target interface function.
- an embodiment of the present invention provides a terminal, including any one of the interface calling devices described above.
- the embodiment of the present invention receives an interface call instruction, where the interface call instruction carries an interface identifier and a parameter corresponding to an interface that is required to be loaded by the client script; when the currently running browser kernel in the browser is not the client script corresponding to a target browser kernel, and the first interface function corresponding to the interface identifier provided by the currently running browser kernel and the second interface function provided by the target browser kernel corresponding to the interface identifier are different Obtaining, by the preset interface identifier, a target interface function of the currently running browser kernel; using the parameter as a The input parameter of the target interface function is called, and the target interface function is called.
- the interface functions provided by some interfaces are different, and the interface functions that can be replaced are preset, so that whether the currently running browser kernel is a client or not
- the target browser kernel corresponding to the script the browser can normally execute the client script to call the request of the interface with different parts, thereby avoiding the running error of the client script when calling the interface with the difference, and improving the browser. Compatibility.
- an embodiment of the present invention provides a terminal, including a processor and a memory that stores instructions executable by the processor.
- the processor is configured to: receive an interface call instruction, where the interface call instruction carries an interface identifier and a parameter corresponding to an interface that is required to be loaded by the client script; when the currently running browser kernel in the browser is not the target corresponding to the client script a browser kernel, and the first interface function corresponding to the interface identifier provided by the currently running browser kernel and the second interface function provided by the target browser kernel corresponding to the interface identifier are different, Obtaining, by the preset interface identifier, a target interface function of the currently running browser kernel, where the target interface function is preset according to the second interface function provided by the target browser kernel Determining a third interface function corresponding to the currently running browser kernel; using the parameter as an input parameter of the target interface function, calling the target interface function.
- an embodiment of the present invention provides a computer readable storage medium having instructions stored therein, and when a processor of a terminal executes the instruction, the terminal executes an interface calling method as described above.
- an embodiment of the present invention provides a computer program that, when run on a processor, performs the interface calling method as described above.
- FIG. 1 is a schematic flowchart of an interface calling method according to an embodiment of the present invention.
- FIG. 2 is another schematic flowchart of an interface calling method according to an embodiment of the present invention.
- FIG. 3 is a schematic structural diagram of an interface calling apparatus according to an embodiment of the present invention.
- FIG. 4 is another schematic structural diagram of an interface calling apparatus according to an embodiment of the present invention.
- FIG. 5 is a schematic structural diagram of a terminal according to an embodiment of the present disclosure.
- FIG. 6 is still another schematic structural diagram of an interface calling apparatus according to an embodiment of the present invention.
- the embodiment of the invention provides an interface calling method, device and terminal, and receives an interface calling instruction, where the interface calling instruction carries an interface identifier and a parameter corresponding to an interface that needs to be invoked by the client script; when the browser is currently running
- the browser kernel is not the target browser kernel corresponding to the client script, and the interface identifier is determined when the interface function corresponding to the interface identifier provided by the currently running browser kernel and the target browser kernel respectively is different.
- the target interface function is a preset interface function; and the parameter is used as an input parameter of the target interface function, and the target interface function is called.
- the interface functions provided by some interfaces are different, and the interface functions that can be replaced are preset, so that whether the currently running browser kernel is a client or not
- the target browser kernel corresponding to the script the browser can normally execute the client script to call the request of the partial difference interface, thereby avoiding the running error of the client script when calling the part of the difference interface, and improving the compatibility of the browser.
- the interface calling method, device and terminal provided by the embodiment of the present invention are respectively described in detail below with reference to FIG.
- FIG. 1 is a schematic flowchart of a method for invoking an interface according to an embodiment of the present invention.
- the method may include the following steps.
- S101 Receive an interface call instruction, where the interface call instruction carries an interface identifier and a parameter corresponding to an interface that is required to be loaded by the client script.
- the method may be used in a browser on a terminal or a browser-like product
- the terminal may be a terminal such as a computer, an IPAD, a mobile phone, or other smart device, specifically, the present invention.
- the embodiment of the invention is not limited at all.
- the browser provides a large number of standard interfaces to the webpage for the client script to be loaded in the webpage, and the browser interprets and executes the client script. For example, when the browser receives the interface call instruction of the client script, the browser runs the interface function corresponding to the target interface specified by the information according to the information carried by the interface call instruction, thereby implementing the corresponding function.
- commonly used browser kernels include: Trident kernel, blink kernel, Gecko kernel, etc.
- interface functions provided between different browser kernels may be different. For convenience of description, this part of the embodiment of the present invention The interface corresponding to the interface function that has the difference is called the difference interface.
- different browser kernels have different parameter parameters and parameter delivery order for interface function designed for interface A that implements the same function, or a browser kernel provides interface B, and another browser kernel does not provide the same. Interface B. Since extensions and web pages in existing browsers are developed based on a particular browser kernel, client-side scripts in web pages and extensions are also developed based on that particular browser kernel. Therefore, the client script can be normal Runs on that particular browser kernel, and when the browser kernel currently running in the browser is not the specific browser kernel, a runtime error may occur.
- browsers are mostly multi-core browsers, that is, browsers include at least two browser kernels.
- the embodiment of the present invention takes a dual-core browser as an example.
- the present invention can be applied to any browser, such as a single-core browser, a multi-core browser, and specifically, the embodiment of the present invention is not limited.
- the interface call instruction is received, and the interface call instruction carries an interface identifier and a parameter corresponding to the interface that the client script needs to invoke.
- the interface identifier may be an interface name or an identifier that is unique to the interface name.
- the embodiment of the present invention does not limit the present invention.
- the browser kernel currently running in the browser is not the target browser kernel corresponding to the client script, and the first interface function corresponding to the interface identifier provided by the currently running browser kernel and the And obtaining, by the target browser, a second interface function corresponding to the interface identifier, acquiring a target interface function of the currently running browser kernel corresponding to the preset interface identifier, where the target interface function is Presetting a third interface function corresponding to the currently running browser kernel according to the second interface function provided by the target browser kernel.
- an interface function for replacing the difference interface is preset.
- the browser is a dual-core browser, which is a Trident kernel and a blink kernel respectively. It can be seen that in the interfaces provided by the Trident kernel and the blink kernel respectively, for the interface that implements the same function, if the Trident kernel and the blink kernel are directed to the interface, The calling interface of the provided interface function is the same, regardless of whether the currently running browser kernel is the target browser kernel corresponding to the client script, the browser can normally run the client script to call the interface request.
- the Trident kernel and the blink kernel differs as follows: the Trident kernel and the blink kernel have different calling specifications for the interface functions provided by the same function (such as the interface name, the number of parameters, the order of delivery, etc.), or A kernel provides an interface to implement a function, and another core does not provide an interface to implement the function. In these cases, if the client script calls this part of the difference interface, a running error will occur.
- the embodiment of the present invention provides an interface calling method for the defect in the existing method, even if the browser kernel currently running in the browser and the browser kernel corresponding to the client script respectively provide an interface for the interface to be called by the client script.
- the client script can still be loaded normally, thereby improving browser compatibility.
- the browser is a dual-core browser, which is a Trident kernel and a blink kernel respectively.
- the target browser kernel corresponding to the client script is a blink kernel
- the currently running browser kernel is a Trident kernel, respectively, in the blink kernel and the Trident kernel.
- there is one difference interface which is represented by interface A.
- the interface function provided by the blink kernel for interface A is InterfaceA, within Trident.
- the interface function provided by the core for interface A is TridentInterfaceA
- the code for calling interface A (see InterfaceA in code 1) in the client script can be as shown in code 1
- the calling specification of the interface function provided by Trident kernel for interface A can be as Code 2 is shown.
- This interface accepts two parameters, the first parameter is the number of times, the second parameter is the URL
- This interface accepts three parameters, the first parameter is the URL, the second parameter is the number of times, the third parameter is the current time
- the interface function InterfaceA provided by the blink kernel receives two parameters, the first parameter represents the number of times, and the second parameter represents The interface function TridentInterfaceA provided by the Trident kernel receives 3 parameters, the first parameter represents the URL, the second parameter represents the number of times, and the third parameter represents the current time. Therefore, if the target browser kernel calls the interface provided by the Trident kernel for the client script of the blink kernel in accordance with the call specification provided by the blink kernel, a runtime error will occur.
- the interface function for replacement is preset. Specifically, according to the interface function provided by one of the browser kernels, a replacement function of another browser kernel is set. For example, for the interface function TridentInterfaceA provided by the Trident kernel, a replacement interface function FakeInterfaceA is preset, wherein the interface function FakeInterfaceA for replacement can be a rewritten interface function, or can be obtained by processing the existing interface function TridentInterfaceA. Interface function.
- the embodiment of the present invention is not limited according to the actual needs.
- the interface function FakeInterfaceA can be as shown in code 3.
- the target browser kernel corresponding to the client script is the blink kernel, and the currently running browser kernel is the Trident kernel, then the preset interface is run.
- the function FakeInterfaceA is the function FakeInterfaceA.
- the interface function provided by the blink kernel for interface A is InterfaceA
- the Trident kernel does not provide interface A. That is, the Trident kernel does not provide an interface function that implements the function corresponding to interface A, and the client script calls interface A (see The code for InterfaceA in Code 1 can be as shown in Code 1.
- a browser kernel provides the interface for an interface, that is, the kernel provides an interface function that implements the function corresponding to the interface; and another browser kernel does not provide the interface function, according to the above
- the kernel provides an interface function for realizing the function corresponding to the interface, and a target interface function is preset for another browser kernel, and the function required to be implemented by the target interface function and the interface function provided by the kernel to implement the function corresponding to the interface need to be implemented.
- the functions are the same and the calling specifications are the same.
- the target interface function may be a combination of existing interface functions (for example, as shown in code 4), or may be a rewritten interface function (for example, as shown in code 5), specifically, according to the actual The case is selected, and the embodiment of the present invention is not limited.
- FakeInterfaceB can realize the functions that the interface function InterfaceA needs to implement by combining the existing interface functions (TridentInterfaceB1, TridentInterfaceB2 and TridentInterfaceB3) in the Trident kernel. By combining these interfaces, you can implement and link The kernel provides the same functionality as interface A.
- the target interface function FakeInterfaceB can be as shown in code 4.
- the target browser kernel corresponding to the client script is the blink kernel, and the currently running browser kernel is the Trident kernel, then the preset interface is run.
- the function FakeInterfaceB is the function FakeInterfaceB.
- an interface function TridentInterfaceC that implements this function is set in advance for the Trident kernel.
- the preset target interface function FakeInterfaceC can be as shown in code 5.
- the target browser kernel corresponding to the client script is the blink kernel, and the currently running browser kernel is the Trident kernel, then the preset target is run.
- the interface function FakeInterfaceC is the interface function FakeInterfaceC.
- the parameter carried in the interface call instruction is used as an input parameter of the target interface function, and the target interface function is called.
- the parameters carried in the interface call instruction are substituted into the target interface function, and the target interface function is executed or executed.
- the compatibility of the browser is improved by pre-normalizing the interfaces provided by different browser kernels.
- an interface call instruction is received, where the interface call instruction carries an interface identifier and a parameter corresponding to an interface that is required to be loaded by the client script; when the browser kernel currently running in the browser is not a target browser kernel corresponding to the client script, and the first interface function corresponding to the interface identifier provided by the currently running browser kernel and the interface identifier corresponding to the interface identifier provided by the target browser kernel
- the second interface function is different, obtaining a target interface function of the currently running browser kernel corresponding to the preset interface identifier; using the parameter as an input parameter of the target interface function, calling the target interface function.
- the interface functions provided by some interfaces are different, and the interface functions that can be replaced are preset, so that whether the currently running browser kernel is a client or not
- the target browser kernel corresponding to the script the browser can normally execute the client script to call the request of the partial difference interface, thereby avoiding the running error of the client script when calling the part of the difference interface, and improving the compatibility of the browser.
- FIG. 2 is another schematic flowchart of an interface calling method according to an embodiment of the present invention.
- the method may include the following steps.
- S201 Upon receiving the trigger instruction for loading the extension, start a new process to load the main program, and the target browser kernel is loaded in the new process.
- extensions include a main program loaded in a browser and/or a script loaded in a web page.
- the extension is associated with the browser kernel. For example, extensions developed based on the blink kernel can only run normally in the blink kernel. Extensions developed based on the Firefox kernel can only run normally in the Firefox kernel.
- the plugin can only run normally on web pages opened based on the blink kernel, but in web pages that are not opened based on the blink kernel (such as the Trident kernel). A runtime error may occur during runtime.
- the browser includes at least the main process during the running process.
- the rendering process may also include a rendering process. If the rendering process is included, the rendering of the webpage content is performed in the rendering process. If the rendering process is not included, the rendering of the webpage content is performed. Work is done in the main process.
- the extension plug-in includes a main program loaded in the browser, when receiving the trigger instruction for loading the extension, a new process is started to load the main program, and the new process is loaded with the Target browser kernel.
- the browser is a dual-core browser, which is the Trident kernel and the blink kernel respectively.
- the target browser kernel corresponding to the extension is the Trident kernel, and the extension can be automatically loaded when the browser is started, or the browser can be successfully started. Manually load the extension.
- the browser receives the trigger instruction to load the extension, it automatically creates a new page, launches a rendering process loaded with the Trident kernel for the page, and runs the main program corresponding to the extension in the rendering process.
- the main program can run normally in the browser.
- the extension includes a script loaded in a webpage
- the script corresponding to the extension needs to be inserted into the opened webpage, thereby loading the extension by loading the webpage.
- the corresponding script program when a trigger event of opening a webpage is detected (for example, the triggering time may be a triggering event of starting a browser or creating a new tab, etc.), the client script corresponding to the extension that needs to be loaded in the browser is used. Insert the webpage to be opened.
- the extension is a plugin with translation capabilities
- the plugin includes the main program loaded in the browser and the script loaded in the web page.
- a new process is started to load the main program, wherein the target browser core corresponding to the extension is loaded in the new process.
- the client script corresponding to the extension is inserted into the webpage to be opened. Therefore, the text message that needs to be translated on the webpage is obtained by the client script loaded in the webpage, and the obtained text information is sent as an interface parameter to be called to the main program loaded in the browser, and the main program is transmitted through the network.
- the server obtains the translation information of the text information, and finally displays the obtained translation information to the webpage.
- S203 Receive an interface call instruction, where the interface call instruction carries an interface identifier and a parameter corresponding to an interface that is required to be loaded by the client script.
- the interface call instruction In the process of loading the webpage, the interface call instruction is received, and the interface call instruction carries an interface identifier and a parameter corresponding to the interface that the client script needs to invoke.
- the interface identifier may be an interface name or an identifier that is unique to the interface name. Specifically, the embodiment of the present invention does not limit the present invention.
- the browser kernel currently running in the browser is not the target browser kernel corresponding to the client script, and the first interface function corresponding to the interface identifier provided by the currently running browser kernel and the When there is a difference between the second interface function corresponding to the interface identifier provided by the target browser kernel, the interface identifier corresponding to the interface function of the currently running browser kernel is queried from the preset information base according to the interface identifier.
- the interface functions provided by the interface are different, and an interface function for replacing the interfaces with different differences is preset, and the preset interface functions and pairs are set.
- the interface identifier should be saved in the preset information base. Therefore, according to the interface identifier carried by the interface call instruction, it can be known whether there is a difference in the interface function provided by the interface to be called in different browser kernels. When receiving the interface call instruction, obtain the type of the browser kernel currently running in the browser.
- the browser kernel currently running in the browser is referred to as the first browser kernel; according to the target corresponding to the client script
- the type of the browser kernel identifying whether the type of the first browser kernel is consistent with the type of the target browser kernel; if not, the interface identifier carried by the interface call instruction identifies that the interface to be called is provided in the first browser kernel Whether the interface function is different from the interface function provided in the target browser kernel; if yes, querying, according to the interface identifier, the interface identifier corresponding to the interface function of the currently running browser kernel from the preset information base.
- the parameter carried in the interface call instruction is used as an input parameter of the target interface function, and the target interface function is called.
- the parameters carried in the interface call instruction are substituted into the target interface function, and the target interface function is executed or executed.
- the compatibility of the browser is improved by pre-normalizing the interfaces provided by different browser kernels.
- an interface call instruction is received, where the interface call instruction carries an interface identifier and a parameter corresponding to an interface that is required to be loaded by the client script; when the browser kernel currently running in the browser is not a target browser kernel corresponding to the client script, and the first interface function corresponding to the interface identifier provided by the currently running browser kernel and the interface identifier corresponding to the interface identifier provided by the target browser kernel
- the second interface function is different, obtaining a target interface function of the currently running browser kernel corresponding to the preset interface identifier; using the parameter as an input parameter of the target interface function, calling the target interface function.
- the interface functions provided by some interfaces are different, and the interface functions that can be replaced are preset, so that whether the currently running browser kernel is a client or not
- the target browser kernel corresponding to the script the browser can normally execute the client script to call the request of the partial difference interface, thereby avoiding the running error of the client script when calling the part of the difference interface, and improving the compatibility of the browser.
- the device embodiment of the present invention is the same as the method embodiment of the present invention, and is used to perform the method described in the method embodiment of the present invention.
- the device embodiment of the present invention only shows a part related to the device embodiment of the present invention. If the specific technical details are not disclosed, please refer to the description of the method embodiment of the present invention. One by one.
- FIG. 3 is a schematic structural diagram of an interface invoking device according to an embodiment of the present invention.
- the device may be applied to a browser, including: a receiving module 101, a determining module 102, and a call. Module 103.
- the receiving module 101 is configured to receive an interface call instruction, where the interface call instruction carries an interface identifier and a parameter corresponding to an interface that is required to be loaded by the client script.
- the determining module 102 is configured to: when the browser kernel currently running in the browser is not the target browser kernel corresponding to the client script, and the first interface corresponding to the interface identifier provided by the currently running browser kernel And obtaining a target interface function of the currently running browser kernel corresponding to the preset interface identifier, where the function and the second interface function corresponding to the interface identifier provided by the target browser kernel are different,
- the target interface function is a third interface function corresponding to the currently running browser kernel according to the second interface function provided by the target browser kernel.
- the calling module 103 is configured to invoke the parameter as the input parameter of the target interface function, and invoke the target interface function.
- an interface call instruction is received, where the interface call instruction carries an interface identifier and a parameter corresponding to an interface that is required to be loaded by the client script; when the browser kernel currently running in the browser is not Determining, according to the target browser kernel corresponding to the client script, the interface function corresponding to the interface identifier provided by the currently running browser kernel and the target browser kernel respectively
- the target interface function of the currently running browser kernel, the target interface function is a preset interface function; the parameter is used as an input parameter of the target interface function, and the target interface function is called.
- the interface functions provided by some interfaces are different, and the interface functions that can be replaced are preset, so that whether the currently running browser kernel is a client or not
- the target browser kernel corresponding to the script the browser can normally execute the client script to call the request of the partial difference interface, thereby avoiding the running error of the client script when calling the part of the difference interface, and improving the compatibility of the browser.
- FIG. 4 is another schematic structural diagram of an interface invoking device according to an embodiment of the present invention.
- the device may include: a receiving module 201, a determining module 202, a calling module 203, and an insertion.
- the receiving module 201 is configured to receive an interface call instruction, where the interface call instruction carries an interface identifier and a parameter corresponding to an interface that needs to be invoked by the client script.
- the determining module 202 is configured to: when the browser kernel currently running in the browser is not the target browser kernel corresponding to the client script, and the first interface corresponding to the interface identifier provided by the currently running browser kernel Function and Obtaining, by the target browser kernel, a second interface function corresponding to the interface identifier, acquiring a target interface function of the currently running browser kernel corresponding to the preset interface identifier, the target interface function Presetting a third interface function corresponding to the currently running browser kernel according to the second interface function provided by the target browser kernel.
- the calling module 203 is configured to invoke the parameter as an input parameter of the target interface function, and invoke the target interface function.
- the client script is a script program included in the extension in the browser, and the module 204 is configured to: when the trigger event of opening the webpage is detected, the browser needs to be loaded.
- the client script corresponding to the extension plugin is inserted into the webpage to be opened.
- the extension further includes a main program loaded in the browser, and the startup module 205 is configured to start a new process to load the main program when receiving a trigger instruction for loading the extension.
- the target browser kernel is loaded in the new process.
- the returning module 206 is configured to return a result of the calling of the target interface function.
- the determining module 202 is specifically configured to:
- the interface identifier is queried from the preset information base according to the interface function of the currently running browser kernel;
- an interface call instruction is received, where the interface call instruction carries an interface identifier and a parameter corresponding to an interface that is required to be loaded by the client script; when the browser kernel currently running in the browser is not a target browser kernel corresponding to the client script, and the first interface function corresponding to the interface identifier provided by the currently running browser kernel and the interface identifier corresponding to the interface identifier provided by the target browser kernel
- the second interface function is different, obtaining a target interface function of the currently running browser kernel corresponding to the preset interface identifier; using the parameter as an input parameter of the target interface function, calling the target interface function.
- the interface functions provided by some interfaces are different, and the interface functions that can be replaced are preset, so that whether the currently running browser kernel is a client or not
- the target browser kernel corresponding to the script the browser can normally execute the client script to call the request of the partial difference interface, thereby avoiding the running error of the client script when calling the part of the difference interface, and improving the compatibility of the browser.
- FIG. 5 is a schematic structural diagram of a terminal according to an embodiment of the present invention.
- Terminal 10 includes an interface calling device as described above.
- the terminal may include: a smart phone, a computer, a tablet computer, a notebook computer, a palmtop computer, and a terminal device such as a mobile Internet device (MID) or a PAD.
- MID mobile Internet device
- PAD PAD
- the embodiment of the present invention is not limited.
- the terminal 10 includes any interface calling device as described above, and the terminal receives an interface calling instruction, where the interface calling instruction carries an interface identifier and a parameter corresponding to an interface that needs to be invoked by the client script;
- the browser kernel currently running in the browser is not the target browser kernel corresponding to the client script, and the first interface function corresponding to the interface identifier and the target browser kernel provided by the currently running browser kernel are provided.
- the input parameter, the target interface function is called.
- the interface functions provided by some interfaces are different, and the interface functions that can be replaced are preset, so that whether the currently running browser kernel is a client or not
- the target browser kernel corresponding to the script the browser can normally execute the client script to call the request of the partial difference interface, thereby avoiding the running error of the client script when calling the part of the difference interface, and improving the compatibility of the browser.
- FIG. 6 is another schematic structural diagram of an interface calling apparatus according to an embodiment of the present invention, for performing an interface calling method disclosed in an embodiment of the present invention, where the apparatus may include: at least one processor 301, for example, The CPU, at least one network interface 304 or other user interface 303, memory 305, at least one communication bus 302. Communication bus 302 is used to implement connection communication between these components.
- the user interface 303 can optionally include a USB interface and other standard interfaces and wired interfaces.
- Network interface 304 may optionally include a Wi-Fi interface as well as other wireless interfaces.
- the memory 305 may include a high speed RAM memory and may also include a non-volatile memory such as at least one disk memory.
- the memory 305 can optionally include at least one storage device located remotely from the aforementioned processor 301. As shown in FIG. 6, an operating system 3051 and an application 3052 may be included in the memory 305 as a computer storage medium.
- the memory 305 stores the following elements, executable modules or data structures, or a subset thereof, or their extension set:
- An operating system 3051 including various system programs for implementing various basic services and processing hardware-based tasks;
- the application 3052 includes various setting programs of a data block parameter setting program of the target network data, a partitioning program of the target data block, a comparison program of the target data block and the data block in the database, and a deletion program of the target data block, and the like. To achieve a variety of application services.
- the processor 301 is configured to invoke a program stored in the memory 305 to perform the following operations:
- the interface call instruction carries an interface identifier and a parameter corresponding to an interface that is required to be loaded by the client script
- the browser kernel currently running in the browser is not the target browser kernel corresponding to the client script, and the first interface function corresponding to the interface identifier provided by the currently running browser kernel and the target browsing Obtaining a target interface function of the currently running browser kernel corresponding to the preset interface identifier, where the second interface function corresponding to the interface identifier is different, and the target interface function is The second interface function provided by the target browser kernel performs a preset third interface function corresponding to the currently running browser kernel;
- the target interface function is invoked by using the parameter as an input parameter of the target interface function.
- the client script is a script program included in an extension in the browser, and the processor 301 executes the receiving interface call instruction, where the interface call instruction carries a load client script.
- the following operations are also performed:
- the client script corresponding to the extension that needs to be loaded in the browser is inserted into the webpage to be opened.
- the extension further includes a main program loaded in a browser, and the processor 301 executes the receiving interface calling instruction, where the interface calling instruction carries an interface corresponding to the calling client script to be called.
- the following operations are also performed:
- a new process is started to load the main program, and the target browser kernel is loaded in the new process.
- the processor 301 performs: when the browser kernel currently running in the browser is not the target browser kernel corresponding to the client script, and the currently running browser kernel provides the same When the first interface function corresponding to the interface identifier is different from the second interface function corresponding to the interface identifier provided by the target browser kernel, the currently running browser corresponding to the preset interface identifier is obtained.
- the operation of the kernel's target interface function including the following:
- the interface identifier is queried from the preset information base according to the interface function of the currently running browser kernel;
- the processor 301 performs the input parameter that uses the parameter as the target interface function. After the operation of the target interface function is invoked, the method further includes:
- an interface call instruction is received, where the interface call instruction carries an interface identifier and a parameter corresponding to an interface that is required to be loaded by the client script; when the browser kernel currently running in the browser is not a target browser kernel corresponding to the client script, and the first interface function corresponding to the interface identifier provided by the currently running browser kernel and the first interface corresponding to the interface identifier provided by the target browser kernel When there is a difference between the two interface functions, obtaining a target interface function of the currently running browser kernel corresponding to the preset interface identifier; using the parameter as an input parameter of the target interface function, calling the target interface function .
- the interface functions provided by some interfaces are different, and the interface functions that can be replaced are preset, so that whether the currently running browser kernel is a client or not
- the target browser kernel corresponding to the script the browser can normally execute the client script to call the request of the partial difference interface, thereby avoiding the running error of the client script when calling the part of the difference interface, and improving the compatibility of the browser.
- modules or units in all the embodiments of the present invention may be implemented by a general-purpose integrated circuit, such as a CPU (Central Processing Unit) or an ASIC (Application Specific Integrated Circuit).
- a CPU Central Processing Unit
- ASIC Application Specific Integrated Circuit
- a system, apparatus, or device such as a computer-based system, a system including a processor, or other system that can fetch instructions and execute instructions from an instruction execution system, apparatus, or device), or in conjunction with such instructions to execute a system, apparatus, or device.
- a "computer-readable medium" can be any apparatus that can contain, store, communicate, propagate, or transport a program for use in an instruction execution system, apparatus, or device, or in conjunction with the instruction execution system, apparatus, or device.
- computer readable media include the following: electrical connections (electronic devices) having one or more wires, portable computer disk cartridges (magnetic devices), random access memory (RAM), Read only memory (ROM), erasable editable read only memory (EPROM or flash memory), fiber optic devices, and portable compact disk read only memory (CDROM).
- the computer readable medium may even be a paper or other suitable medium on which the program can be printed, as it may be optically scanned, for example by paper or other medium, followed by editing, interpretation or, if appropriate, other suitable The method is processed to obtain the program electronically and then stored in computer memory.
- each functional unit in each embodiment of the present invention may be integrated into one processing module, or each unit may exist physically separately, or two or more units may be integrated into one module.
- the above integrated modules can be implemented in the form of hardware or in the form of software functional modules.
- the integrated modules, if implemented in the form of software functional modules and sold or used as stand-alone products, may also be stored in a computer readable storage medium.
- the above mentioned storage medium may be a read only memory, a magnetic disk or an optical disk or the like.
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
- Information Transfer Between Computers (AREA)
- Telephone Function (AREA)
Abstract
An interface calling method, an interface calling device and a terminal, which can improve the compatibility of a browser. The method comprises: receiving an interface calling instruction, the interface calling instruction carrying an interface identifier and parameters, corresponding to an interface which needs to be called for loading a client script (S101); when a browser kernel, which is currently operated in a browser, is not a target browser kernel corresponding to the client script, and a first interface function, which is provided by the currently operated browser kernel and corresponds to the interface identifier, is different from a second interface function, which is provided by the target browser kernel and corresponds to the interface identifier, acquiring a pre-set target interface function, which corresponds to the interface identifier, of the currently operated browser kernel (S102); and taking the parameters as input parameters of the target interface function, and calling the target interface function (S103).
Description
相关申请的交叉引用Cross-reference to related applications
本申请基于申请号为201510229507.9,申请日为2015年5月7日的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此引入本申请作为参考。The present application is based on the Chinese Patent Application No. 20151022950
本发明涉及计算机技术领域,尤其涉及一种接口调用方法、装置及终端。The present invention relates to the field of computer technologies, and in particular, to an interface calling method, apparatus, and terminal.
随着互联网技术的发展,浏览器已成为移动终端上必备的应用软件之一,通过移动终端上的浏览器浏览网页时,浏览器内核对网页语法进行解释并渲染网页。通常,浏览器内核提供了大量接口,客户端脚本可以调用这些接口,浏览器解释执行网页中加载的客户端脚本,从而实现网页的动态展示效果,增强网页的交互性。With the development of Internet technology, the browser has become one of the necessary application software on the mobile terminal. When browsing the webpage through the browser on the mobile terminal, the browser kernel interprets the webpage syntax and renders the webpage. Generally, the browser kernel provides a large number of interfaces, and the client script can call these interfaces. The browser interprets the client scripts loaded in the execution webpage, thereby realizing the dynamic display effect of the webpage and enhancing the interactivity of the webpage.
目前,浏览器大多为多核浏览器,即浏览器中包括至少两个浏览器内核,然而,不同的浏览器内核之间所提供的接口函数可能会存在差异。例如:不同的浏览器内核针对实现相同功能的接口A所设计的接口函数的参数数目、参数的传递顺序不一样,或者是浏览器中某一浏览器内核提供接口B,而另一浏览器内核不提供该接口B。同时,由于现有浏览器中的扩展插件和网页都是基于某一特定的浏览器内核开发出来的,网页和扩展插件中的客户端脚本也基于该特定的浏览器内核开发。因此,客户端脚本可以正常运行在该特定的浏览器内核上。然而,若浏览器中当前运行的浏览器内核不是客户端脚本对应的特定浏览器内核,且当前运行的浏览器内核与该特定浏览器内核,针对该客户端脚本需要调用的接口存在上述差异时,网页或扩展插件将出现运行错误,导致浏览器的兼容性差。Currently, most browsers are multi-core browsers, that is, the browser includes at least two browser kernels. However, the interface functions provided between different browser kernels may differ. For example, different browser kernels have different parameters for the interface functions designed by interface A that implement the same function, and the order of parameters is different, or one browser kernel in the browser provides interface B, and another browser kernel. This interface B is not provided. At the same time, since extensions and web pages in existing browsers are developed based on a particular browser kernel, client-side scripts in web pages and extensions are also developed based on that particular browser kernel. Therefore, the client script can run normally on that particular browser kernel. However, if the currently running browser kernel in the browser is not a specific browser kernel corresponding to the client script, and the currently running browser kernel and the specific browser kernel have the above difference for the interface that the client script needs to invoke , webpages or extensions will run incorrectly, resulting in poor browser compatibility.
发明内容Summary of the invention
本发明实施例提供一种接口调用方法、装置及终端,可以提升浏览器的兼容性。The embodiment of the invention provides an interface calling method, device and terminal, which can improve browser compatibility.
第一方面,本发明实施例提供一种接口调用方法,包括:In a first aspect, an embodiment of the present invention provides an interface calling method, including:
接收接口调用指令,所述接口调用指令携带有加载客户端脚本需要调用的接口对应的接口标识和参数;Receiving an interface call instruction, where the interface call instruction carries an interface identifier and a parameter corresponding to an interface that is required to be loaded by the client script;
当浏览器中当前运行的浏览器内核不是所述客户端脚本对应的目标浏览器内核,且所述当前运行的浏览器内核提供的与所述接口标识对应的第一接口函数和所述目标浏览器内核
提供的与所述接口标识对应的第二接口函数存在差异时,获取预设的所述接口标识对应的所述当前运行的浏览器内核的目标接口函数,所述目标接口函数为根据所述目标浏览器内核提供的所述第二接口函数进行预设的与所述当前运行的浏览器内核对应的第三接口函数;When the browser kernel currently running in the browser is not the target browser kernel corresponding to the client script, and the first interface function corresponding to the interface identifier provided by the currently running browser kernel and the target browsing Kernel
Obtaining a target interface function of the currently running browser kernel corresponding to the preset interface identifier when the second interface function corresponding to the interface identifier is different, and the target interface function is according to the target The second interface function provided by the browser kernel performs a preset third interface function corresponding to the currently running browser kernel;
将所述参数作为所述目标接口函数的输入参数,调用所述目标接口函数。The target interface function is invoked by using the parameter as an input parameter of the target interface function.
在第一方面的第一种可能的实现方式中,所述客户端脚本为所述浏览器中的扩展插件所包括的脚本程序;In a first possible implementation manner of the first aspect, the client script is a script program included in an extension in the browser;
在所述接收接口调用指令之前,所述方法还包括:Before the receiving interface calls the instruction, the method further includes:
当检测到打开网页的触发事件时,将浏览器中需要加载的扩展插件对应的客户端脚本插入待打开的网页中。When the trigger event of opening the webpage is detected, the client script corresponding to the extension that needs to be loaded in the browser is inserted into the webpage to be opened.
结合第一方面的第一种可能的实现方式,在第一方面的第二种可能的实现方式中,所述扩展插件还包括在浏览器中加载的主程序;In conjunction with the first possible implementation of the first aspect, in a second possible implementation of the first aspect, the extension further includes a main program loaded in a browser;
所述接收接口调用指令,所述接口调用指令携带有加载客户端脚本需要调用的接口对应的接口标识和参数之前,所述方法还包括:The receiving interface calls an instruction, where the interface calling instruction carries an interface identifier and a parameter corresponding to an interface that needs to be invoked by the client script, the method further includes:
接收到加载该扩展插件的触发指令时,启动新的进程加载所述主程序,所述新的进程中加载有所述目标浏览器内核。Upon receiving the trigger instruction to load the extension, a new process is started to load the main program, and the target browser kernel is loaded in the new process.
结合第一方面,在第一方面的第三种可能的实现方式中,所述当浏览器中当前运行的浏览器内核不是所述客户端脚本对应的目标浏览器内核,且所述当前运行的浏览器内核提供的与所述接口标识对应的第一接口函数和所述目标浏览器内核提供的与所述接口标识对应的第二接口函数存在差异时,获取预设的所述接口标识对应的所述当前运行的浏览器内核的目标接口函数包括:In conjunction with the first aspect, in a third possible implementation manner of the first aspect, the browser kernel currently running in the browser is not the target browser kernel corresponding to the client script, and the currently running Obtaining, by the browser kernel, a first interface function corresponding to the interface identifier and a second interface function corresponding to the interface identifier provided by the target browser kernel, obtaining a preset corresponding to the interface identifier The target interface function of the currently running browser kernel includes:
当浏览器中当前运行的浏览器内核不是所述客户端脚本对应的目标浏览器内核,且所述当前运行的浏览器内核提供的与所述接口标识对应的第一接口函数和所述目标浏览器内核提供的与所述接口标识对应的第二接口函数存在差异时,根据所述接口标识,从预设信息库中查询该接口标识对应所述当前运行的浏览器内核的接口函数;When the browser kernel currently running in the browser is not the target browser kernel corresponding to the client script, and the first interface function corresponding to the interface identifier provided by the currently running browser kernel and the target browsing When there is a difference between the second interface function corresponding to the interface identifier provided by the kernel, the interface identifier is queried from the preset information base according to the interface function of the currently running browser kernel;
将所查询到的接口函数确定为目标接口函数。Determine the interface function that is queried as the target interface function.
结合第一方面或第一方面的上述任意一种可能的实现方式,在第一方面的第四种可能的实现方式中,所述将所述参数作为所述目标接口函数的输入参数,调用所述目标接口函数之后,所述方法还包括:With reference to the first aspect or any one of the foregoing possible implementation manners of the first aspect, in a fourth possible implementation manner of the first aspect, the parameter is used as an input parameter of the target interface function, After the target interface function, the method further includes:
返回所述目标接口函数的调用结果。Returns the result of the call to the target interface function.
第二方面,本发明实施例提供一种接口调用装置,所述装置应用于浏览器中,包括:In a second aspect, an embodiment of the present invention provides an interface calling device, where the device is applied to a browser, including:
接收模块,用于接收接口调用指令,所述接口调用指令携带有加载客户端脚本需要调用
的接口对应的接口标识和参数;a receiving module, configured to receive an interface call instruction, where the interface call instruction carries a load client script that needs to be called
Interface identifier and parameters corresponding to the interface;
确定模块,用于当浏览器中当前运行的浏览器内核不是所述客户端脚本对应的目标浏览器内核,且所述当前运行的浏览器内核提供的与所述接口标识对应的第一接口函数和所述目标浏览器内核提供的与所述接口标识对应的第二接口函数存在差异时,获取预设的所述接口标识对应的所述当前运行的浏览器内核的目标接口函数,所述目标接口函数为根据所述目标浏览器内核提供的所述第二接口函数进行预设的与所述当前运行的浏览器内核对应的第三接口函数;a determining module, configured to: when the currently running browser kernel in the browser is not the target browser kernel corresponding to the client script, and the first interface function corresponding to the interface identifier provided by the currently running browser kernel Obtaining, by the target browser kernel, a second interface function corresponding to the interface identifier, acquiring a target interface function of the currently running browser kernel corresponding to the preset interface identifier, where the target The interface function is a third interface function corresponding to the currently running browser kernel according to the second interface function provided by the target browser kernel;
调用模块,用于将所述参数作为所述目标接口函数的输入参数,调用所述目标接口函数。The calling module is configured to invoke the parameter as the input parameter of the target interface function, and invoke the target interface function.
在第二方面的第一种可能的实现方式中,所述客户端脚本为所述浏览器中的扩展插件所包括的脚本程序,所述装置还包括:In a first possible implementation of the second aspect, the client script is a script program included in the extension in the browser, and the device further includes:
插入模块,用于当检测到打开网页的触发事件时,将浏览器中需要加载的扩展插件对应的客户端脚本插入待打开的网页中。The inserting module is configured to insert a client script corresponding to the extension that needs to be loaded in the browser into the webpage to be opened when the triggering event of opening the webpage is detected.
结合第二方面的第一种可能的实现方式,在第二方面的第二种可能的实现方式中,所述扩展插件还包括在浏览器中加载的主程序,所述装置还包括:In conjunction with the first possible implementation of the second aspect, in a second possible implementation of the second aspect, the extension further includes a main program loaded in a browser, the device further comprising:
启动模块,用于接收到加载该扩展插件的触发指令时,启动新的进程加载所述主程序,所述新的进程中加载有所述目标浏览器内核。The startup module is configured to start a new process to load the main program when the trigger instruction for loading the extension is received, and the target browser kernel is loaded in the new process.
结合第二方面,在第二方面的第三种可能的实现方式中,所述确定模块具体用于:With reference to the second aspect, in a third possible implementation manner of the second aspect, the determining module is specifically configured to:
当浏览器中当前运行的浏览器内核不是所述客户端脚本对应的目标浏览器内核,且所述当前运行的浏览器内核提供的与所述接口标识对应的第一接口函数和所述目标浏览器内核提供的与所述接口标识对应的第二接口函数存在差异时,根据所述接口标识,从预设信息库中查询该接口标识对应所述当前运行的浏览器内核的接口函数;When the browser kernel currently running in the browser is not the target browser kernel corresponding to the client script, and the first interface function corresponding to the interface identifier provided by the currently running browser kernel and the target browsing When there is a difference between the second interface function corresponding to the interface identifier provided by the kernel, the interface identifier is queried from the preset information base according to the interface function of the currently running browser kernel;
将所查询到的接口函数确定为目标接口函数。Determine the interface function that is queried as the target interface function.
结合第二方面或第二方面的上述任意一种可能的实现方式,在第二方面的第四种可能的实现方式中,所述装置还包括:With reference to the second aspect, or any one of the foregoing possible implementation manners of the second aspect, in a fourth possible implementation manner of the second aspect, the device further includes:
返回模块,用于返回所述目标接口函数的调用结果。A return module for returning a result of the call of the target interface function.
第三方面,本发明实施例提供一种终端,包括如上所述的任意一种接口调用装置。In a third aspect, an embodiment of the present invention provides a terminal, including any one of the interface calling devices described above.
实施本发明实施例,接收接口调用指令,所述接口调用指令携带有加载客户端脚本需要调用的接口对应的接口标识和参数;当浏览器中当前运行的浏览器内核不是所述客户端脚本对应的目标浏览器内核,且所述当前运行的浏览器内核提供的与所述接口标识对应的第一接口函数和所述目标浏览器内核提供的与所述接口标识对应的第二接口函数存在差异时,获取预设的所述接口标识对应的所述当前运行的浏览器内核的目标接口函数;将所述参数作为所
述目标接口函数的输入参数,调用所述目标接口函数。采用本发明实施例,根据浏览器中不同的浏览器内核针对某些接口提供的接口函数存在差异的情况,预先设置可供替换的接口函数,因此,不管当前运行的浏览器内核是不是客户端脚本对应的目标浏览器内核,浏览器均可以正常执行客户端脚本调用这部分存在差异的接口的请求,从而避免客户端脚本因调用这部分存在差异的接口时而出现运行错误的情况,提升浏览器的兼容性。The embodiment of the present invention receives an interface call instruction, where the interface call instruction carries an interface identifier and a parameter corresponding to an interface that is required to be loaded by the client script; when the currently running browser kernel in the browser is not the client script corresponding to a target browser kernel, and the first interface function corresponding to the interface identifier provided by the currently running browser kernel and the second interface function provided by the target browser kernel corresponding to the interface identifier are different Obtaining, by the preset interface identifier, a target interface function of the currently running browser kernel; using the parameter as a
The input parameter of the target interface function is called, and the target interface function is called. According to the embodiment of the present invention, according to different browser kernels in the browser, the interface functions provided by some interfaces are different, and the interface functions that can be replaced are preset, so that whether the currently running browser kernel is a client or not The target browser kernel corresponding to the script, the browser can normally execute the client script to call the request of the interface with different parts, thereby avoiding the running error of the client script when calling the interface with the difference, and improving the browser. Compatibility.
第四方面,本发明实施例提供一种终端,包括处理器和存储处理器可执行的指令的存储器。处理器用于:接收接口调用指令,所述接口调用指令携带有加载客户端脚本需要调用的接口对应的接口标识和参数;当浏览器中当前运行的浏览器内核不是所述客户端脚本对应的目标浏览器内核,且所述当前运行的浏览器内核提供的与所述接口标识对应的第一接口函数和所述目标浏览器内核提供的与所述接口标识对应的第二接口函数存在差异时,获取预设的所述接口标识对应的所述当前运行的浏览器内核的目标接口函数,所述目标接口函数为根据所述目标浏览器内核提供的所述第二接口函数进行预设的与所述当前运行的浏览器内核对应的第三接口函数;将所述参数作为所述目标接口函数的输入参数,调用所述目标接口函数。In a fourth aspect, an embodiment of the present invention provides a terminal, including a processor and a memory that stores instructions executable by the processor. The processor is configured to: receive an interface call instruction, where the interface call instruction carries an interface identifier and a parameter corresponding to an interface that is required to be loaded by the client script; when the currently running browser kernel in the browser is not the target corresponding to the client script a browser kernel, and the first interface function corresponding to the interface identifier provided by the currently running browser kernel and the second interface function provided by the target browser kernel corresponding to the interface identifier are different, Obtaining, by the preset interface identifier, a target interface function of the currently running browser kernel, where the target interface function is preset according to the second interface function provided by the target browser kernel Determining a third interface function corresponding to the currently running browser kernel; using the parameter as an input parameter of the target interface function, calling the target interface function.
第五方面,本发明实施例提供一种计算机可读存储介质,具有存储于其中的指令,当终端的处理器执行该指令时,终端执行如上所述的接口调用方法。In a fifth aspect, an embodiment of the present invention provides a computer readable storage medium having instructions stored therein, and when a processor of a terminal executes the instruction, the terminal executes an interface calling method as described above.
第六方面,本发明实施例提供一种计算机程序,当其在处理器上运行时,执行如上所述的接口调用方法。In a sixth aspect, an embodiment of the present invention provides a computer program that, when run on a processor, performs the interface calling method as described above.
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments will be briefly described below. It is obvious that the drawings in the following description are some embodiments of the present invention, Those skilled in the art can also obtain other drawings based on these drawings without paying any creative work.
图1是本发明实施例提供的一种接口调用方法的流程示意图;1 is a schematic flowchart of an interface calling method according to an embodiment of the present invention;
图2是本发明实施例提供的一种接口调用方法的另一流程示意图;2 is another schematic flowchart of an interface calling method according to an embodiment of the present invention;
图3是本发明实施例提供的一种接口调用装置的结构示意图;3 is a schematic structural diagram of an interface calling apparatus according to an embodiment of the present invention;
图4是本发明实施例提供的一种接口调用装置的另一结构示意图;4 is another schematic structural diagram of an interface calling apparatus according to an embodiment of the present invention;
图5是本发明实施例提供的一种终端的结构示意图;FIG. 5 is a schematic structural diagram of a terminal according to an embodiment of the present disclosure;
图6是本发明实施例提供的一种接口调用装置的又一结构示意图。FIG. 6 is still another schematic structural diagram of an interface calling apparatus according to an embodiment of the present invention.
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描
述,显然,所描述的实施例仅是本发明的一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention.
It is apparent that the described embodiments are only a part of the embodiments of the invention, and not all of the embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts are within the scope of the present invention.
本发明实施例提供了一种接口调用方法、装置及终端,接收接口调用指令,所述接口调用指令携带有加载客户端脚本需要调用的接口对应的接口标识和参数;当浏览器中当前运行的浏览器内核不是所述客户端脚本对应的目标浏览器内核,且所述当前运行的浏览器内核和所述目标浏览器内核分别提供的该接口标识对应的接口函数存在差异时,确定该接口标识对应的所述当前运行的浏览器内核的目标接口函数,所述目标接口函数为预设的接口函数;将所述参数作为所述目标接口函数的输入参数,调用所述目标接口函数。采用本发明实施例,根据浏览器中不同的浏览器内核针对某些接口提供的接口函数存在差异的情况,预先设置可供替换的接口函数,因此,不管当前运行的浏览器内核是不是客户端脚本对应的目标浏览器内核,浏览器均可以正常执行客户端脚本调用该部分差异接口的请求,从而,避免客户端脚本因调用这部分差异接口时而出现运行错误的情况,提升浏览器的兼容性。下面将结合附图1-附图6对本发明实施例提供的一种接口调用方法、装置及终端分别进行详细介绍。The embodiment of the invention provides an interface calling method, device and terminal, and receives an interface calling instruction, where the interface calling instruction carries an interface identifier and a parameter corresponding to an interface that needs to be invoked by the client script; when the browser is currently running The browser kernel is not the target browser kernel corresponding to the client script, and the interface identifier is determined when the interface function corresponding to the interface identifier provided by the currently running browser kernel and the target browser kernel respectively is different. Corresponding to the target interface function of the currently running browser kernel, the target interface function is a preset interface function; and the parameter is used as an input parameter of the target interface function, and the target interface function is called. According to the embodiment of the present invention, according to different browser kernels in the browser, the interface functions provided by some interfaces are different, and the interface functions that can be replaced are preset, so that whether the currently running browser kernel is a client or not The target browser kernel corresponding to the script, the browser can normally execute the client script to call the request of the partial difference interface, thereby avoiding the running error of the client script when calling the part of the difference interface, and improving the compatibility of the browser. . The interface calling method, device and terminal provided by the embodiment of the present invention are respectively described in detail below with reference to FIG.
请参见图1,图1是本发明实施例提供的一种接口调用方法的流程示意图,在本发明实施例中,该方法可以包括以下步骤。Referring to FIG. 1, FIG. 1 is a schematic flowchart of a method for invoking an interface according to an embodiment of the present invention. In the embodiment of the present invention, the method may include the following steps.
S101:接收接口调用指令,所述接口调用指令携带有加载客户端脚本需要调用的接口对应的接口标识和参数。S101: Receive an interface call instruction, where the interface call instruction carries an interface identifier and a parameter corresponding to an interface that is required to be loaded by the client script.
在本发明实施例中,该方法可以用于终端上的浏览器或类似于浏览器的产品中,所述终端可以是计算机、IPAD、手机等终端,也可以是其它智能设备,具体的,本发明实施例不作任何限制。In the embodiment of the present invention, the method may be used in a browser on a terminal or a browser-like product, and the terminal may be a terminal such as a computer, an IPAD, a mobile phone, or other smart device, specifically, the present invention. The embodiment of the invention is not limited at all.
通常,为丰富网页的动态展示效果,增强网页与用户的交互性,浏览器向网页提供了大量标准接口,供网页中加载的客户端脚本调用,浏览器解释、执行该客户端脚本。例如:浏览器接收到客户端脚本的接口调用指令时,根据该接口调用指令携带的信息运行该信息所指定的目标接口对应的接口函数,从而实现相应的功能。目前,常用的浏览器内核有:Trident内核、blink内核、Gecko内核等,然而,不同的浏览器内核之间所提供的接口函数可能会存在差异,为方便描述,本发明实施例中将这部分存在差异的接口函数对应的接口称为差异接口。例如:不同的浏览器内核针对实现相同功能的接口A所设计的接口函数的参数数目、参数的传递顺序不一样,或者是某一浏览器内核提供接口B,而另一浏览器内核不提供该接口B。由于现有浏览器中的扩展插件和网页都是基于某一特定的浏览器内核开发出来的,网页和扩展插件中的客户端脚本也基于该特定的浏览器内核开发。因此,客户端脚本可以正常
运行在该特定的浏览器内核上,而当浏览器中当前运行的浏览器内核不是该特定的浏览器内核时,可能会出现运行错误。Generally, in order to enrich the dynamic display effect of the webpage and enhance the interaction between the webpage and the user, the browser provides a large number of standard interfaces to the webpage for the client script to be loaded in the webpage, and the browser interprets and executes the client script. For example, when the browser receives the interface call instruction of the client script, the browser runs the interface function corresponding to the target interface specified by the information according to the information carried by the interface call instruction, thereby implementing the corresponding function. Currently, commonly used browser kernels include: Trident kernel, blink kernel, Gecko kernel, etc. However, interface functions provided between different browser kernels may be different. For convenience of description, this part of the embodiment of the present invention The interface corresponding to the interface function that has the difference is called the difference interface. For example, different browser kernels have different parameter parameters and parameter delivery order for interface function designed for interface A that implements the same function, or a browser kernel provides interface B, and another browser kernel does not provide the same. Interface B. Since extensions and web pages in existing browsers are developed based on a particular browser kernel, client-side scripts in web pages and extensions are also developed based on that particular browser kernel. Therefore, the client script can be normal
Runs on that particular browser kernel, and when the browser kernel currently running in the browser is not the specific browser kernel, a runtime error may occur.
为提高网页的运行效率,目前,浏览器大多为多核浏览器,即浏览器中包括至少两个浏览器内核。为方便说明,本发明实施例以双核浏览器为例,当然,本发明可以应用于任意浏览器,如单核浏览器、多核浏览器,具体的,本发明实施例不作限制。在加载网页的过程中,接收接口调用指令,所述接口调用指令携带有加载客户端脚本需要调用的接口对应的接口标识和参数。其中,所述接口标识可以是接口名称,也可以是与接口名称唯一对应的标识符,具体的,本发明实施例不作限制。In order to improve the efficiency of webpages, browsers are mostly multi-core browsers, that is, browsers include at least two browser kernels. For convenience of description, the embodiment of the present invention takes a dual-core browser as an example. Of course, the present invention can be applied to any browser, such as a single-core browser, a multi-core browser, and specifically, the embodiment of the present invention is not limited. In the process of loading the webpage, the interface call instruction is received, and the interface call instruction carries an interface identifier and a parameter corresponding to the interface that the client script needs to invoke. The interface identifier may be an interface name or an identifier that is unique to the interface name. Specifically, the embodiment of the present invention does not limit the present invention.
S102:当浏览器中当前运行的浏览器内核不是所述客户端脚本对应的目标浏览器内核,且所述当前运行的浏览器内核提供的与所述接口标识对应的第一接口函数和所述目标浏览器内核提供的与所述接口标识对应的第二接口函数存在差异时,获取预设的所述接口标识对应的所述当前运行的浏览器内核的目标接口函数,所述目标接口函数为根据所述目标浏览器内核提供的所述第二接口函数进行预设的与所述当前运行的浏览器内核对应的第三接口函数。S102: The browser kernel currently running in the browser is not the target browser kernel corresponding to the client script, and the first interface function corresponding to the interface identifier provided by the currently running browser kernel and the And obtaining, by the target browser, a second interface function corresponding to the interface identifier, acquiring a target interface function of the currently running browser kernel corresponding to the preset interface identifier, where the target interface function is Presetting a third interface function corresponding to the currently running browser kernel according to the second interface function provided by the target browser kernel.
本发明实施例中,根据浏览器中不同的浏览器内核针对某些接口提供的接口函数存在差异的情况,预先设置供差异接口替换的接口函数。为方便说明,假设浏览器为双核浏览器,分别为Trident内核和blink内核,可知,在Trident内核和blink内核分别提供的接口中,针对实现相同功能的接口,若Trident内核和blink内核针对该接口提供的接口函数的调用规范相同,则不管当前运行的浏览器内核是不是客户端脚本对应的目标浏览器内核,浏览器均可以正常运行客户端脚本调用该接口的请求。若Trident内核和blink内核提供的接口存在如下差异时:Trident内核和blink内核对实现相同功能所提供的接口函数的调用规范不相同(如接口名称、参数数目、传递顺序不相同等),或者是某一内核提供有实现某一功能的接口,另一内核未提供实现该功能的接口,在这些情况下,若客户端脚本调用这部分差异接口,将出现运行错误。In the embodiment of the present invention, according to the difference in interface functions provided by different browser kernels for some interfaces in the browser, an interface function for replacing the difference interface is preset. For convenience of explanation, it is assumed that the browser is a dual-core browser, which is a Trident kernel and a blink kernel respectively. It can be seen that in the interfaces provided by the Trident kernel and the blink kernel respectively, for the interface that implements the same function, if the Trident kernel and the blink kernel are directed to the interface, The calling interface of the provided interface function is the same, regardless of whether the currently running browser kernel is the target browser kernel corresponding to the client script, the browser can normally run the client script to call the interface request. If the interface provided by the Trident kernel and the blink kernel differs as follows: the Trident kernel and the blink kernel have different calling specifications for the interface functions provided by the same function (such as the interface name, the number of parameters, the order of delivery, etc.), or A kernel provides an interface to implement a function, and another core does not provide an interface to implement the function. In these cases, if the client script calls this part of the difference interface, a running error will occur.
本发明实施例针对现有方法中的该缺陷设计一种接口调用方法,即便浏览器中当前运行的浏览器内核和客户端脚本对应的浏览器内核分别针对客户端脚本所要调用的接口提供的接口函数存在差异,仍可正常加载该客户端脚本,从而,可以提升浏览器的兼容性。为方便说明,假设浏览器为双核浏览器,分别为Trident内核和blink内核,客户端脚本对应的目标浏览器内核为blink内核,当前运行的浏览器内核为Trident内核,在blink内核和Trident内核分别提供的所有接口中,存在1个差异接口,用接口A表示。The embodiment of the present invention provides an interface calling method for the defect in the existing method, even if the browser kernel currently running in the browser and the browser kernel corresponding to the client script respectively provide an interface for the interface to be called by the client script. There is a difference in the function, and the client script can still be loaded normally, thereby improving browser compatibility. For convenience of explanation, it is assumed that the browser is a dual-core browser, which is a Trident kernel and a blink kernel respectively. The target browser kernel corresponding to the client script is a blink kernel, and the currently running browser kernel is a Trident kernel, respectively, in the blink kernel and the Trident kernel. Among all the interfaces provided, there is one difference interface, which is represented by interface A.
作为一种示例,假设blink内核针对接口A提供的接口函数为InterfaceA,Trident内
核针对接口A提供的接口函数为TridentInterfaceA,则客户端脚本中调用接口A(见代码1中InterfaceA)的代码可以如代码1所示,而Trident内核针对接口A提供的接口函数的调用规范可以如代码2所示。As an example, assume that the interface function provided by the blink kernel for interface A is InterfaceA, within Trident.
The interface function provided by the core for interface A is TridentInterfaceA, then the code for calling interface A (see InterfaceA in code 1) in the client script can be as shown in code 1, and the calling specification of the interface function provided by Trident kernel for interface A can be as Code 2 is shown.
代码1:Code 1:
//blink客户端脚本//blink client script
function blinkExtensionFunction()Function blinkExtensionFunction()
{{
....//功能代码....//function code
//调用blink接口,function InterfaceA(count,url)/ / Call the blink interface, function InterfaceA (count, url)
//此接口接受两个参数,第一个参数为次数,第二个参数为网址/ / This interface accepts two parameters, the first parameter is the number of times, the second parameter is the URL
chrome.InterfaceA(100,"http://www.liebao.cn");chrome.InterfaceA(100,"http://www.liebao.cn");
....//功能代码....//function code
}}
代码2:Code 2:
//Trident内核相同功能的接口//The interface of the same function of the Trident kernel
//此接口接受三个参数,第一个参数为网址,第二个参数为次数,第三个参数为当前时间/ / This interface accepts three parameters, the first parameter is the URL, the second parameter is the number of times, the third parameter is the current time
function TridentInterfaceA(url,count,date);Function TridentInterfaceA(url,count,date);
由代码1和代码2可预先获知blink内核和Trident内核针对接口A提供的接口函数存在差异,其中,blink内核提供的接口函数InterfaceA接收2个参数,第一个参数表示次数,第二个参数表示网址;Trident内核提供的接口函数TridentInterfaceA接收3个参数,第一个参数表示网址,第二个参数表示次数,第三个参数表示当前时间。因此,若目标浏览器内核为blink内核的客户端脚本按照blink内核提供的调用规范调用Trident内核提供的接口,将出现运行错误。本发明实施例中,针对同一接口,不同的浏览器内核提供的接口函数的调用规范不一致的情况,预先设置供替换的接口函数。具体的,根据其中一个浏览器内核提供的接口函数,设置另一个浏览器内核的替换函数。例如:针对Trident内核提供的接口函数TridentInterfaceA预先设置一个供替换的接口函数FakeInterfaceA,其中,供替换的接口函数FakeInterfaceA可以是重新编写的接口函数,也可以是通过现有的接口函数TridentInterfaceA处理后得到的接口函数。具体的,根据实际需要设定,本发明实施例不作限制。作为一种示例,接口函数FakeInterfaceA可以如代码3所示。It can be known in advance from code 1 and code 2 that there is a difference between the interface function provided by the blink kernel and the Trident kernel for interface A. The interface function InterfaceA provided by the blink kernel receives two parameters, the first parameter represents the number of times, and the second parameter represents The interface function TridentInterfaceA provided by the Trident kernel receives 3 parameters, the first parameter represents the URL, the second parameter represents the number of times, and the third parameter represents the current time. Therefore, if the target browser kernel calls the interface provided by the Trident kernel for the client script of the blink kernel in accordance with the call specification provided by the blink kernel, a runtime error will occur. In the embodiment of the present invention, for the same interface, when the calling specifications of the interface functions provided by different browser kernels are inconsistent, the interface function for replacement is preset. Specifically, according to the interface function provided by one of the browser kernels, a replacement function of another browser kernel is set. For example, for the interface function TridentInterfaceA provided by the Trident kernel, a replacement interface function FakeInterfaceA is preset, wherein the interface function FakeInterfaceA for replacement can be a rewritten interface function, or can be obtained by processing the existing interface function TridentInterfaceA. Interface function. Specifically, the embodiment of the present invention is not limited according to the actual needs. As an example, the interface function FakeInterfaceA can be as shown in code 3.
代码3
Code 3
//脚本中间层,对接口进行转换/ / Script middle layer, the interface is converted
//chrome为预先定义的全局对象//chrome is a predefined global object
chrome.FakeInterfaceA=function(count,url)chrome.FakeInterfaceA=function(count,url)
{{
......//辅助代码...//Auxiliary code
//其中Date()表示获取当前时间//where Date() means to get the current time
//这里调用Trident内核的接口/ / Here call the interface of the Trident kernel
var result=TridentInterfaceA(url,count,Date());Var result=TridentInterfaceA(url,count,Date());
......//辅助代码...//Auxiliary code
return result;Return result;
}}
从而,浏览器在加载客户端脚本时,若该客户端脚本需要调用接口A,客户端脚本对应的目标浏览器内核为blink内核,当前运行的浏览器内核为Trident内核,则运行预先设置的接口函数FakeInterfaceA。Therefore, when the browser loads the client script, if the client script needs to call interface A, the target browser kernel corresponding to the client script is the blink kernel, and the currently running browser kernel is the Trident kernel, then the preset interface is run. The function FakeInterfaceA.
作为另一种示例,假设blink内核针对接口A提供的接口函数为InterfaceA,Trident内核未提供接口A,即Trident内核未提供有实现接口A对应的功能的接口函数,客户端脚本调用接口A(见代码1中InterfaceA)的代码可以如代码1所示。本发明实施例中,若对于某一接口,一个浏览器内核提供该接口,即该内核提供有实现该接口对应的功能的接口函数;而另一个浏览器内核未提供该接口函数,则根据上述内核提供有实现该接口对应的功能的接口函数,针对另一个浏览器内核预先设置目标接口函数,所述目标接口函数需要实现的功能与上述内核提供有实现该接口对应的功能的接口函数需要实现的功能相同,且调用规范也相同。具体实现中,目标接口函数可以是现有的接口函数的组合(例如:如代码4所示),也可以是重新编写的接口函数(例如:如代码5所示),具体的,可根据实际情况进行选取,本发明实施例不作限制。作为一种示例,假设目标接口函数FakeInterfaceB可以通过组合Trident内核中现有的接口函数(TridentInterfaceB1,TridentInterfaceB2 和TridentInterfaceB3)来实现接口函数InterfaceA需要实现的功能,则通过组合这几个接口,可以实现和blink内核提供的接口A一样的功能。例如:目标接口函数FakeInterfaceB可以如代码4所示。As another example, assume that the interface function provided by the blink kernel for interface A is InterfaceA, and the Trident kernel does not provide interface A. That is, the Trident kernel does not provide an interface function that implements the function corresponding to interface A, and the client script calls interface A (see The code for InterfaceA in Code 1 can be as shown in Code 1. In the embodiment of the present invention, if a browser kernel provides the interface for an interface, that is, the kernel provides an interface function that implements the function corresponding to the interface; and another browser kernel does not provide the interface function, according to the above The kernel provides an interface function for realizing the function corresponding to the interface, and a target interface function is preset for another browser kernel, and the function required to be implemented by the target interface function and the interface function provided by the kernel to implement the function corresponding to the interface need to be implemented. The functions are the same and the calling specifications are the same. In a specific implementation, the target interface function may be a combination of existing interface functions (for example, as shown in code 4), or may be a rewritten interface function (for example, as shown in code 5), specifically, according to the actual The case is selected, and the embodiment of the present invention is not limited. As an example, suppose the target interface function FakeInterfaceB can realize the functions that the interface function InterfaceA needs to implement by combining the existing interface functions (TridentInterfaceB1, TridentInterfaceB2 and TridentInterfaceB3) in the Trident kernel. By combining these interfaces, you can implement and link The kernel provides the same functionality as interface A. For example: the target interface function FakeInterfaceB can be as shown in code 4.
代码4:Code 4:
//chrome为预先定义的全局对象//chrome is a predefined global object
chrome.FakeInterfaceB=function(count,url){
chrome.FakeInterfaceB=function(count,url){
var result;Var result;
......//辅助代码...//Auxiliary code
//组合Trident接口,实现相同功能/ / Combine the Trident interface to achieve the same function
//下面的组合方式仅作为示例,实际情况多变。/ / The following combination is only an example, the actual situation is changeable.
result=TridentInterfaceB1(count);Result=TridentInterfaceB1(count);
......//辅助代码...//Auxiliary code
result=TridentInterfaceB2(url);Result=TridentInterfaceB2(url);
......//辅助代码...//Auxiliary code
result=TridentInterfaceB3();Result=TridentInterfaceB3();
......//辅助代码...//Auxiliary code
return result;Return result;
}}
从而,浏览器在加载客户端脚本时,若该客户端脚本需要调用接口A,客户端脚本对应的目标浏览器内核为blink内核,当前运行的浏览器内核为Trident内核,则运行预先设置的接口函数FakeInterfaceB。Therefore, when the browser loads the client script, if the client script needs to call interface A, the target browser kernel corresponding to the client script is the blink kernel, and the currently running browser kernel is the Trident kernel, then the preset interface is run. The function FakeInterfaceB.
作为另一种示例,假设无法通过组合Trident内核中现有的接口函数来实现接口A需要实现的功能,则预先为Trident内核设置一个实现该功能的接口函数TridentInterfaceC。从而,预设的目标接口函数FakeInterfaceC可以如代码5所示。As another example, if it is not possible to implement the functions that interface A needs to implement by combining the existing interface functions in the Trident kernel, an interface function TridentInterfaceC that implements this function is set in advance for the Trident kernel. Thus, the preset target interface function FakeInterfaceC can be as shown in code 5.
代码5Code 5
//chrome为预先定义的全局对象//chrome is a predefined global object
chrome.FakeInterfaceC=function(count,url){chrome.FakeInterfaceC=function(count,url){
......//辅助代码...//Auxiliary code
//这里调用本发明为Trident内核添加的接口/ / Here to call the interface added by the invention for the Trident kernel
var result=TridentInterfaceC(url,count);Var result=TridentInterfaceC(url,count);
......//辅助代码...//Auxiliary code
return result;Return result;
}}
从而,浏览器在加载客户端脚本时,若该客户端脚本需要调用接口A,客户端脚本对应的目标浏览器内核为blink内核,当前运行的浏览器内核为Trident内核,则运行预先设置的目标接口函数FakeInterfaceC。Therefore, when the browser loads the client script, if the client script needs to call interface A, the target browser kernel corresponding to the client script is the blink kernel, and the currently running browser kernel is the Trident kernel, then the preset target is run. The interface function FakeInterfaceC.
S103:将所述参数作为所述目标接口函数的输入参数,调用所述目标接口函数。
S103: Call the parameter as an input parameter of the target interface function, and invoke the target interface function.
由步骤S102确定出目标接口函数后,将接口调用指令中携带的参数作为该目标接口函数的输入参数,调用所述目标接口函数。换句话说,将接口调用指令中携带的参数代入目标接口函数中,运行或执行该目标接口函数。从而,通过预先对不同的浏览器内核所提供的接口进行规范化处理,提升浏览器的兼容性。After the target interface function is determined in step S102, the parameter carried in the interface call instruction is used as an input parameter of the target interface function, and the target interface function is called. In other words, the parameters carried in the interface call instruction are substituted into the target interface function, and the target interface function is executed or executed. Thus, the compatibility of the browser is improved by pre-normalizing the interfaces provided by different browser kernels.
在本发明实施例描述的接口调用方法中,接收接口调用指令,所述接口调用指令携带有加载客户端脚本需要调用的接口对应的接口标识和参数;当浏览器中当前运行的浏览器内核不是所述客户端脚本对应的目标浏览器内核,且所述当前运行的浏览器内核提供的与所述接口标识对应的第一接口函数和所述目标浏览器内核提供的与所述接口标识对应的第二接口函数存在差异时,获取预设的所述接口标识对应的所述当前运行的浏览器内核的目标接口函数;将所述参数作为所述目标接口函数的输入参数,调用所述目标接口函数。采用本发明实施例,根据浏览器中不同的浏览器内核针对某些接口提供的接口函数存在差异的情况,预先设置可供替换的接口函数,因此,不管当前运行的浏览器内核是不是客户端脚本对应的目标浏览器内核,浏览器均可以正常执行客户端脚本调用该部分差异接口的请求,从而,避免客户端脚本因调用这部分差异接口时而出现运行错误的情况,提升浏览器的兼容性。In the interface calling method described in the embodiment of the present invention, an interface call instruction is received, where the interface call instruction carries an interface identifier and a parameter corresponding to an interface that is required to be loaded by the client script; when the browser kernel currently running in the browser is not a target browser kernel corresponding to the client script, and the first interface function corresponding to the interface identifier provided by the currently running browser kernel and the interface identifier corresponding to the interface identifier provided by the target browser kernel When the second interface function is different, obtaining a target interface function of the currently running browser kernel corresponding to the preset interface identifier; using the parameter as an input parameter of the target interface function, calling the target interface function. According to the embodiment of the present invention, according to different browser kernels in the browser, the interface functions provided by some interfaces are different, and the interface functions that can be replaced are preset, so that whether the currently running browser kernel is a client or not The target browser kernel corresponding to the script, the browser can normally execute the client script to call the request of the partial difference interface, thereby avoiding the running error of the client script when calling the part of the difference interface, and improving the compatibility of the browser. .
请参见图2,图2是本发明实施例提供的一种接口调用方法的另一流程示意图,在本发明实施例中,该方法可以包括以下步骤。Referring to FIG. 2, FIG. 2 is another schematic flowchart of an interface calling method according to an embodiment of the present invention. In the embodiment of the present invention, the method may include the following steps.
S201:接收到加载扩展插件的触发指令时,启动新的进程加载所述主程序,所述新的进程中加载有所述目标浏览器内核。S201: Upon receiving the trigger instruction for loading the extension, start a new process to load the main program, and the target browser kernel is loaded in the new process.
由于浏览器内核提供了强大的接口,开发人员能够基于这些接口开发出各式各样的扩展插件,比如:自动代理、密码保险箱、广告过滤等插件,这些扩展插件不仅能够实现新的功能,而且还能更改当前网页的展现方式。通常,扩展插件包括在浏览器中加载的主程序和/或在网页中加载的脚本程序,具体实现过程中,扩展插件与浏览器内核相关联。例如:基于blink内核开发出来的扩展插件只能正常运行在blink内核中,基于Firefox内核开发出来的扩展插件只能正常运行在Firefox内核中。因此,在多核浏览器中,若安装了一个基于blink内核的扩展插件,则该插件只能正常运行在基于blink内核打开的网页中,而在不是基于blink内核(如Trident内核)打开的网页中运行时可能会出现运行错误。Because the browser kernel provides a powerful interface, developers can develop a variety of extensions based on these interfaces, such as: automatic proxy, password safe, ad filtering and other plug-ins, these extensions can not only achieve new features, but also You can also change how the current page is displayed. Typically, extensions include a main program loaded in a browser and/or a script loaded in a web page. In the implementation, the extension is associated with the browser kernel. For example, extensions developed based on the blink kernel can only run normally in the blink kernel. Extensions developed based on the Firefox kernel can only run normally in the Firefox kernel. Therefore, in a multi-core browser, if an extension based on the blink kernel is installed, the plugin can only run normally on web pages opened based on the blink kernel, but in web pages that are not opened based on the blink kernel (such as the Trident kernel). A runtime error may occur during runtime.
通常,浏览器在运行过程中至少包括主进程,当然,还可以包括渲染进程,若包含有渲染进程,则网页内容的渲染工作在渲染进程中进行,若不包含渲染进程,则网页内容的渲染工作在主进程中进行。本发明实施例中,若扩展插件包括在浏览器中加载的主程序,则接收到加载扩展插件的触发指令时,启动新的进程加载所述主程序,所述新的进程中加载有所述目标浏览器内核。
Generally, the browser includes at least the main process during the running process. Of course, the rendering process may also include a rendering process. If the rendering process is included, the rendering of the webpage content is performed in the rendering process. If the rendering process is not included, the rendering of the webpage content is performed. Work is done in the main process. In the embodiment of the present invention, if the extension plug-in includes a main program loaded in the browser, when receiving the trigger instruction for loading the extension, a new process is started to load the main program, and the new process is loaded with the Target browser kernel.
例如:假设浏览器为双核浏览器,分别为Trident内核和blink内核,扩展插件对应的目标浏览器内核为Trident内核,则可以在启动浏览器时自动加载该扩展插件,也可以是浏览器启动成功后手动加载该扩展插件。当浏览器接收到加载扩展插件的触发指令时,自动创建一个新页面,针对该页面启动一个加载有Trident内核的渲染进程,并在渲染进程中运行该扩展插件对应的主程序。从而,不管浏览器当前运行的浏览器内核是不是该扩展插件中的主程序对应的目标浏览器内核,该主程序均可以正常运行在浏览器中。For example, suppose the browser is a dual-core browser, which is the Trident kernel and the blink kernel respectively. The target browser kernel corresponding to the extension is the Trident kernel, and the extension can be automatically loaded when the browser is started, or the browser can be successfully started. Manually load the extension. When the browser receives the trigger instruction to load the extension, it automatically creates a new page, launches a rendering process loaded with the Trident kernel for the page, and runs the main program corresponding to the extension in the rendering process. Thus, regardless of whether the browser kernel currently running by the browser is the target browser kernel corresponding to the main program in the extension, the main program can run normally in the browser.
S202:当检测到打开网页的触发事件时,将浏览器中需要加载的扩展插件对应的客户端脚本插入待打开的网页中。S202: When detecting a trigger event of opening a webpage, insert a client script corresponding to the extension that needs to be loaded in the browser into the webpage to be opened.
若扩展插件包括在网页中加载的脚本程序,则在浏览器中加载该扩展插件时,需要将该扩展插件对应的脚本程序插入至打开的网页中,从而,通过加载该网页的方式加载扩展插件中对应的脚本程序。本发明实施例中,当检测到打开网页的触发事件时(例如:该触发时间可以是启动浏览器或新建标签页的触发事件等),将浏览器中需要加载的扩展插件对应的客户端脚本插入待打开的网页中。If the extension includes a script loaded in a webpage, when the extension is loaded in the browser, the script corresponding to the extension needs to be inserted into the opened webpage, thereby loading the extension by loading the webpage. The corresponding script program. In the embodiment of the present invention, when a trigger event of opening a webpage is detected (for example, the triggering time may be a triggering event of starting a browser or creating a new tab, etc.), the client script corresponding to the extension that needs to be loaded in the browser is used. Insert the webpage to be opened.
例如:假设该扩展插件为具备翻译功能的插件,则该插件包括在浏览器中加载的主程序和在网页中加载的脚本程序。接收到加载该扩展插件的触发指令时,启动新的进程加载所述主程序,其中,该新的进程中加载有所述扩展插件对应的目标浏览器内核。并在检测到打开网页的触发事件时,将该扩展插件对应的客户端脚本插入待打开的网页中。从而,通过加载在网页中的客户端脚本获取网页上需要进行翻译的文字信息,并将所获取到的文字信息作为需要调用的接口参数发送给加载在浏览器中主程序,主程序通过网络向服务器获取该文字信息的翻译信息,最终将所获得的翻译信息显示至网页。For example: Suppose the extension is a plugin with translation capabilities, the plugin includes the main program loaded in the browser and the script loaded in the web page. Upon receiving the trigger instruction to load the extension, a new process is started to load the main program, wherein the target browser core corresponding to the extension is loaded in the new process. And when the trigger event of opening the webpage is detected, the client script corresponding to the extension is inserted into the webpage to be opened. Therefore, the text message that needs to be translated on the webpage is obtained by the client script loaded in the webpage, and the obtained text information is sent as an interface parameter to be called to the main program loaded in the browser, and the main program is transmitted through the network. The server obtains the translation information of the text information, and finally displays the obtained translation information to the webpage.
S203:接收接口调用指令,所述接口调用指令携带有加载客户端脚本需要调用的接口对应的接口标识和参数。S203: Receive an interface call instruction, where the interface call instruction carries an interface identifier and a parameter corresponding to an interface that is required to be loaded by the client script.
在加载网页的过程中,接收接口调用指令,所述接口调用指令携带有加载客户端脚本需要调用的接口对应的接口标识和参数。其中,所述接口标识可以是接口名称,也可以是与接口名称唯一对应的标识符,具体的,本发明实施例不作限制。In the process of loading the webpage, the interface call instruction is received, and the interface call instruction carries an interface identifier and a parameter corresponding to the interface that the client script needs to invoke. The interface identifier may be an interface name or an identifier that is unique to the interface name. Specifically, the embodiment of the present invention does not limit the present invention.
S204:当浏览器中当前运行的浏览器内核不是所述客户端脚本对应的目标浏览器内核,且所述当前运行的浏览器内核提供的与所述接口标识对应的第一接口函数和所述目标浏览器内核提供的与所述接口标识对应的第二接口函数存在差异时,根据所述接口标识,从预设信息库中查询该接口标识对应所述当前运行的浏览器内核的接口函数。S204: The browser kernel currently running in the browser is not the target browser kernel corresponding to the client script, and the first interface function corresponding to the interface identifier provided by the currently running browser kernel and the When there is a difference between the second interface function corresponding to the interface identifier provided by the target browser kernel, the interface identifier corresponding to the interface function of the currently running browser kernel is queried from the preset information base according to the interface identifier.
在一种实现方式中,根据浏览器中不同的浏览器内核针对接口提供的接口函数存在差异的情况,预先设置供这些存在差异的接口替换的接口函数,并将该预先设置的接口函数和对
应的接口标识保存在预设信息库中,从而,根据接口调用指令所携带的接口标识即可获知所要调用的接口在不同的浏览器内核中所提供的接口函数是否存在差异。当接收到接口调用指令时,获取浏览器中当前运行的浏览器内核的类型,为方便描述,将浏览器中当前运行的浏览器内核称为第一浏览器内核;根据客户端脚本对应的目标浏览器内核的类型,识别第一浏览器内核的类型是否与目标浏览器内核的类型一致;若不一致,根据该接口调用指令携带的接口标识识别所要调用的接口在第一浏览器内核中提供的接口函数是否与在目标浏览器内核中提供的接口函数存在差异;若是,根据所述接口标识,从预设信息库中查询该接口标识对应所述当前运行的浏览器内核的接口函数。In an implementation manner, according to different browser APIs in the browser, the interface functions provided by the interface are different, and an interface function for replacing the interfaces with different differences is preset, and the preset interface functions and pairs are set.
The interface identifier should be saved in the preset information base. Therefore, according to the interface identifier carried by the interface call instruction, it can be known whether there is a difference in the interface function provided by the interface to be called in different browser kernels. When receiving the interface call instruction, obtain the type of the browser kernel currently running in the browser. For convenience of description, the browser kernel currently running in the browser is referred to as the first browser kernel; according to the target corresponding to the client script The type of the browser kernel, identifying whether the type of the first browser kernel is consistent with the type of the target browser kernel; if not, the interface identifier carried by the interface call instruction identifies that the interface to be called is provided in the first browser kernel Whether the interface function is different from the interface function provided in the target browser kernel; if yes, querying, according to the interface identifier, the interface identifier corresponding to the interface function of the currently running browser kernel from the preset information base.
S205:将所查询到的接口函数确定为目标接口函数。S205: Determine the interface function that is queried as a target interface function.
S206:将所述参数作为所述目标接口函数的输入参数,调用所述目标接口函数。S206: Call the parameter as an input parameter of the target interface function, and invoke the target interface function.
由步骤S205确定出目标接口函数后,将接口调用指令中携带的参数作为该目标接口函数的输入参数,调用所述目标接口函数。换句话说,将接口调用指令中携带的参数代入目标接口函数中,运行或执行该目标接口函数。从而,通过预先对不同的浏览器内核所提供的接口进行规范化处理,提升浏览器的兼容性。After the target interface function is determined in step S205, the parameter carried in the interface call instruction is used as an input parameter of the target interface function, and the target interface function is called. In other words, the parameters carried in the interface call instruction are substituted into the target interface function, and the target interface function is executed or executed. Thus, the compatibility of the browser is improved by pre-normalizing the interfaces provided by different browser kernels.
S207:返回所述目标接口函数的调用结果。S207: Return a result of calling the target interface function.
获取调用所述目标接口函数后的输出参数,将该输出参数作为调用结果,向客户端脚本返回所述目标接口函数的调用结果,以便客户端脚本采用该调用结果继续执行后续操作。Obtaining an output parameter after calling the target interface function, and using the output parameter as a result of the call, returning a result of the calling of the target interface function to the client script, so that the client script continues to perform the subsequent operation by using the calling result.
在本发明实施例描述的接口调用方法中,接收接口调用指令,所述接口调用指令携带有加载客户端脚本需要调用的接口对应的接口标识和参数;当浏览器中当前运行的浏览器内核不是所述客户端脚本对应的目标浏览器内核,且所述当前运行的浏览器内核提供的与所述接口标识对应的第一接口函数和所述目标浏览器内核提供的与所述接口标识对应的第二接口函数存在差异时,获取预设的所述接口标识对应的所述当前运行的浏览器内核的目标接口函数;将所述参数作为所述目标接口函数的输入参数,调用所述目标接口函数。采用本发明实施例,根据浏览器中不同的浏览器内核针对某些接口提供的接口函数存在差异的情况,预先设置可供替换的接口函数,因此,不管当前运行的浏览器内核是不是客户端脚本对应的目标浏览器内核,浏览器均可以正常执行客户端脚本调用该部分差异接口的请求,从而,避免客户端脚本因调用这部分差异接口时而出现运行错误的情况,提升浏览器的兼容性。In the interface calling method described in the embodiment of the present invention, an interface call instruction is received, where the interface call instruction carries an interface identifier and a parameter corresponding to an interface that is required to be loaded by the client script; when the browser kernel currently running in the browser is not a target browser kernel corresponding to the client script, and the first interface function corresponding to the interface identifier provided by the currently running browser kernel and the interface identifier corresponding to the interface identifier provided by the target browser kernel When the second interface function is different, obtaining a target interface function of the currently running browser kernel corresponding to the preset interface identifier; using the parameter as an input parameter of the target interface function, calling the target interface function. According to the embodiment of the present invention, according to different browser kernels in the browser, the interface functions provided by some interfaces are different, and the interface functions that can be replaced are preset, so that whether the currently running browser kernel is a client or not The target browser kernel corresponding to the script, the browser can normally execute the client script to call the request of the partial difference interface, thereby avoiding the running error of the client script when calling the part of the difference interface, and improving the compatibility of the browser. .
下面为本发明装置实施例,本发明装置实施例与本发明方法实施例属于同一构思,用于执行本发明方法实施例中描述的方法。为了便于说明,本发明装置实施例仅示出与本发明装置实施例相关的部分,具体技术细节未揭示的,请参照本发明方法实施例的描述,此处不再
一一赘述。The following is an embodiment of the device of the present invention. The device embodiment of the present invention is the same as the method embodiment of the present invention, and is used to perform the method described in the method embodiment of the present invention. For ease of description, the device embodiment of the present invention only shows a part related to the device embodiment of the present invention. If the specific technical details are not disclosed, please refer to the description of the method embodiment of the present invention.
One by one.
请参见图3,图3是本发明实施例提供的一种接口调用装置的结构示意图,在本发明实施例中,该装置可以应用于浏览器中,包括:接收模块101、确定模块102和调用模块103。Referring to FIG. 3, FIG. 3 is a schematic structural diagram of an interface invoking device according to an embodiment of the present invention. In the embodiment of the present invention, the device may be applied to a browser, including: a receiving module 101, a determining module 102, and a call. Module 103.
接收模块101,用于接收接口调用指令,所述接口调用指令携带有加载客户端脚本需要调用的接口对应的接口标识和参数。The receiving module 101 is configured to receive an interface call instruction, where the interface call instruction carries an interface identifier and a parameter corresponding to an interface that is required to be loaded by the client script.
确定模块102,用于当浏览器中当前运行的浏览器内核不是所述客户端脚本对应的目标浏览器内核,且所述当前运行的浏览器内核提供的与所述接口标识对应的第一接口函数和所述目标浏览器内核提供的与所述接口标识对应的第二接口函数存在差异时,获取预设的所述接口标识对应的所述当前运行的浏览器内核的目标接口函数,所述目标接口函数为根据所述目标浏览器内核提供的所述第二接口函数进行预设的与所述当前运行的浏览器内核对应的第三接口函数。The determining module 102 is configured to: when the browser kernel currently running in the browser is not the target browser kernel corresponding to the client script, and the first interface corresponding to the interface identifier provided by the currently running browser kernel And obtaining a target interface function of the currently running browser kernel corresponding to the preset interface identifier, where the function and the second interface function corresponding to the interface identifier provided by the target browser kernel are different, The target interface function is a third interface function corresponding to the currently running browser kernel according to the second interface function provided by the target browser kernel.
调用模块103,用于将所述参数作为所述目标接口函数的输入参数,调用所述目标接口函数。The calling module 103 is configured to invoke the parameter as the input parameter of the target interface function, and invoke the target interface function.
在本发明实施例描述的接口调用装置中,接收接口调用指令,所述接口调用指令携带有加载客户端脚本需要调用的接口对应的接口标识和参数;当浏览器中当前运行的浏览器内核不是所述客户端脚本对应的目标浏览器内核,且所述当前运行的浏览器内核和所述目标浏览器内核分别提供的该接口标识对应的接口函数存在差异时,确定该接口标识对应的所述当前运行的浏览器内核的目标接口函数,所述目标接口函数为预设的接口函数;将所述参数作为所述目标接口函数的输入参数,调用所述目标接口函数。采用本发明实施例,根据浏览器中不同的浏览器内核针对某些接口提供的接口函数存在差异的情况,预先设置可供替换的接口函数,因此,不管当前运行的浏览器内核是不是客户端脚本对应的目标浏览器内核,浏览器均可以正常执行客户端脚本调用该部分差异接口的请求,从而,避免客户端脚本因调用这部分差异接口时而出现运行错误的情况,提升浏览器的兼容性。In the interface calling device described in the embodiment of the present invention, an interface call instruction is received, where the interface call instruction carries an interface identifier and a parameter corresponding to an interface that is required to be loaded by the client script; when the browser kernel currently running in the browser is not Determining, according to the target browser kernel corresponding to the client script, the interface function corresponding to the interface identifier provided by the currently running browser kernel and the target browser kernel respectively The target interface function of the currently running browser kernel, the target interface function is a preset interface function; the parameter is used as an input parameter of the target interface function, and the target interface function is called. According to the embodiment of the present invention, according to different browser kernels in the browser, the interface functions provided by some interfaces are different, and the interface functions that can be replaced are preset, so that whether the currently running browser kernel is a client or not The target browser kernel corresponding to the script, the browser can normally execute the client script to call the request of the partial difference interface, thereby avoiding the running error of the client script when calling the part of the difference interface, and improving the compatibility of the browser. .
请参见图4,图4是本发明实施例提供的一种接口调用装置的另一结构示意图,在本发明实施例中,该装置可以包括:接收模块201、确定模块202、调用模块203、插入模块204、启动模块205和返回模块206。Referring to FIG. 4, FIG. 4 is another schematic structural diagram of an interface invoking device according to an embodiment of the present invention. In the embodiment of the present invention, the device may include: a receiving module 201, a determining module 202, a calling module 203, and an insertion. Module 204, startup module 205, and return module 206.
接收模块201,用于接收接口调用指令,所述接口调用指令携带有加载客户端脚本需要调用的接口对应的接口标识和参数。The receiving module 201 is configured to receive an interface call instruction, where the interface call instruction carries an interface identifier and a parameter corresponding to an interface that needs to be invoked by the client script.
确定模块202,用于当浏览器中当前运行的浏览器内核不是所述客户端脚本对应的目标浏览器内核,且所述当前运行的浏览器内核提供的与所述接口标识对应的第一接口函数和所
述目标浏览器内核提供的与所述接口标识对应的第二接口函数存在差异时,获取预设的所述接口标识对应的所述当前运行的浏览器内核的目标接口函数,所述目标接口函数为根据所述目标浏览器内核提供的所述第二接口函数进行预设的与所述当前运行的浏览器内核对应的第三接口函数。The determining module 202 is configured to: when the browser kernel currently running in the browser is not the target browser kernel corresponding to the client script, and the first interface corresponding to the interface identifier provided by the currently running browser kernel Function and
Obtaining, by the target browser kernel, a second interface function corresponding to the interface identifier, acquiring a target interface function of the currently running browser kernel corresponding to the preset interface identifier, the target interface function Presetting a third interface function corresponding to the currently running browser kernel according to the second interface function provided by the target browser kernel.
调用模块203,用于将所述参数作为所述目标接口函数的输入参数,调用所述目标接口函数。The calling module 203 is configured to invoke the parameter as an input parameter of the target interface function, and invoke the target interface function.
在一种实施例中,所述客户端脚本为所述浏览器中的扩展插件所包括的脚本程序,插入模块204,用于当检测到打开网页的触发事件时,将浏览器中需要加载的扩展插件对应的客户端脚本插入待打开的网页中。In an embodiment, the client script is a script program included in the extension in the browser, and the module 204 is configured to: when the trigger event of opening the webpage is detected, the browser needs to be loaded. The client script corresponding to the extension plugin is inserted into the webpage to be opened.
在一种实施例中,所述扩展插件还包括在浏览器中加载的主程序,启动模块205,用于接收到加载该扩展插件的触发指令时,启动新的进程加载所述主程序,所述新的进程中加载有所述目标浏览器内核。In an embodiment, the extension further includes a main program loaded in the browser, and the startup module 205 is configured to start a new process to load the main program when receiving a trigger instruction for loading the extension. The target browser kernel is loaded in the new process.
返回模块206,用于返回所述目标接口函数的调用结果。The returning module 206 is configured to return a result of the calling of the target interface function.
在一种实施例中,确定模块202具体用于:In an embodiment, the determining module 202 is specifically configured to:
当浏览器中当前运行的浏览器内核不是所述客户端脚本对应的目标浏览器内核,且所述当前运行的浏览器内核提供的与所述接口标识对应的第一接口函数和所述目标浏览器内核提供的与所述接口标识对应的第二接口函数存在差异时,根据所述接口标识,从预设信息库中查询该接口标识对应所述当前运行的浏览器内核的接口函数;When the browser kernel currently running in the browser is not the target browser kernel corresponding to the client script, and the first interface function corresponding to the interface identifier provided by the currently running browser kernel and the target browsing When there is a difference between the second interface function corresponding to the interface identifier provided by the kernel, the interface identifier is queried from the preset information base according to the interface function of the currently running browser kernel;
将所查询到的接口函数确定为目标接口函数。Determine the interface function that is queried as the target interface function.
在本发明实施例描述的接口调用装置中,接收接口调用指令,所述接口调用指令携带有加载客户端脚本需要调用的接口对应的接口标识和参数;当浏览器中当前运行的浏览器内核不是所述客户端脚本对应的目标浏览器内核,且所述当前运行的浏览器内核提供的与所述接口标识对应的第一接口函数和所述目标浏览器内核提供的与所述接口标识对应的第二接口函数存在差异时,获取预设的所述接口标识对应的所述当前运行的浏览器内核的目标接口函数;将所述参数作为所述目标接口函数的输入参数,调用所述目标接口函数。采用本发明实施例,根据浏览器中不同的浏览器内核针对某些接口提供的接口函数存在差异的情况,预先设置可供替换的接口函数,因此,不管当前运行的浏览器内核是不是客户端脚本对应的目标浏览器内核,浏览器均可以正常执行客户端脚本调用该部分差异接口的请求,从而,避免客户端脚本因调用这部分差异接口时而出现运行错误的情况,提升浏览器的兼容性。In the interface calling device described in the embodiment of the present invention, an interface call instruction is received, where the interface call instruction carries an interface identifier and a parameter corresponding to an interface that is required to be loaded by the client script; when the browser kernel currently running in the browser is not a target browser kernel corresponding to the client script, and the first interface function corresponding to the interface identifier provided by the currently running browser kernel and the interface identifier corresponding to the interface identifier provided by the target browser kernel When the second interface function is different, obtaining a target interface function of the currently running browser kernel corresponding to the preset interface identifier; using the parameter as an input parameter of the target interface function, calling the target interface function. According to the embodiment of the present invention, according to different browser kernels in the browser, the interface functions provided by some interfaces are different, and the interface functions that can be replaced are preset, so that whether the currently running browser kernel is a client or not The target browser kernel corresponding to the script, the browser can normally execute the client script to call the request of the partial difference interface, thereby avoiding the running error of the client script when calling the part of the difference interface, and improving the compatibility of the browser. .
请参见图5,图5是本发明实施例提供的一种终端的结构示意图,在本发明实施例中,
终端10包括如上所述的接口调用装置。在本发明实施例中,所述终端可以包括:智能手机、电脑、平板电脑、笔记本电脑、掌上电脑以及移动互联网设备(MID)、PAD等终端设备。具体的,本发明实施例不作限制。Referring to FIG. 5, FIG. 5 is a schematic structural diagram of a terminal according to an embodiment of the present invention.
Terminal 10 includes an interface calling device as described above. In the embodiment of the present invention, the terminal may include: a smart phone, a computer, a tablet computer, a notebook computer, a palmtop computer, and a terminal device such as a mobile Internet device (MID) or a PAD. Specifically, the embodiment of the present invention is not limited.
值得说明的是,终端10包括如上所述的任意一种接口调用装置,该终端接收接口调用指令,所述接口调用指令携带有加载客户端脚本需要调用的接口对应的接口标识和参数;当浏览器中当前运行的浏览器内核不是所述客户端脚本对应的目标浏览器内核,且所述当前运行的浏览器内核提供的与所述接口标识对应的第一接口函数和所述目标浏览器内核提供的与所述接口标识对应的第二接口函数存在差异时,获取预设的所述接口标识对应的所述当前运行的浏览器内核的目标接口函数;将所述参数作为所述目标接口函数的输入参数,调用所述目标接口函数。采用本发明实施例,根据浏览器中不同的浏览器内核针对某些接口提供的接口函数存在差异的情况,预先设置可供替换的接口函数,因此,不管当前运行的浏览器内核是不是客户端脚本对应的目标浏览器内核,浏览器均可以正常执行客户端脚本调用该部分差异接口的请求,从而,避免客户端脚本因调用这部分差异接口时而出现运行错误的情况,提升浏览器的兼容性。It is to be noted that the terminal 10 includes any interface calling device as described above, and the terminal receives an interface calling instruction, where the interface calling instruction carries an interface identifier and a parameter corresponding to an interface that needs to be invoked by the client script; The browser kernel currently running in the browser is not the target browser kernel corresponding to the client script, and the first interface function corresponding to the interface identifier and the target browser kernel provided by the currently running browser kernel are provided. Obtaining a target interface function of the currently running browser kernel corresponding to the preset interface identifier when the second interface function corresponding to the interface identifier is different; using the parameter as the target interface function The input parameter, the target interface function is called. According to the embodiment of the present invention, according to different browser kernels in the browser, the interface functions provided by some interfaces are different, and the interface functions that can be replaced are preset, so that whether the currently running browser kernel is a client or not The target browser kernel corresponding to the script, the browser can normally execute the client script to call the request of the partial difference interface, thereby avoiding the running error of the client script when calling the part of the difference interface, and improving the compatibility of the browser. .
请参见图6,图6是本发明实施例提供的一种接口调用装置的又一结构示意图,用于执行本发明实施例公开的接口调用方法,该装置可以包括:至少一个处理器301,例如CPU,至少一个网络接口304或者其他用户接口303,存储器305,至少一个通信总线302。通信总线302用于实现这些组件之间的连接通信。其中,用户接口303可选的可以包括USB接口以及其他标准接口、有线接口。网络接口304可选的可以包括Wi-Fi接口以及其他无线接口。存储器305可能包含高速RAM存储器,也可能还包括非不稳定的存储器(non-volatile memory),例如至少一个磁盘存储器。存储器305可选的可以包含至少一个位于远离前述处理器301的存储装置。如图6所示,作为一种计算机存储介质的存储器305中可以包括操作系统3051及应用程序3052。Referring to FIG. 6, FIG. 6 is another schematic structural diagram of an interface calling apparatus according to an embodiment of the present invention, for performing an interface calling method disclosed in an embodiment of the present invention, where the apparatus may include: at least one processor 301, for example, The CPU, at least one network interface 304 or other user interface 303, memory 305, at least one communication bus 302. Communication bus 302 is used to implement connection communication between these components. The user interface 303 can optionally include a USB interface and other standard interfaces and wired interfaces. Network interface 304 may optionally include a Wi-Fi interface as well as other wireless interfaces. The memory 305 may include a high speed RAM memory and may also include a non-volatile memory such as at least one disk memory. The memory 305 can optionally include at least one storage device located remotely from the aforementioned processor 301. As shown in FIG. 6, an operating system 3051 and an application 3052 may be included in the memory 305 as a computer storage medium.
在一些实施方式中,存储器305存储了如下的元素,可执行模块或者数据结构,或者他们的子集,或者他们的扩展集:In some implementations, the memory 305 stores the following elements, executable modules or data structures, or a subset thereof, or their extension set:
操作系统3051,包含各种系统程序,用于实现各种基础业务以及处理基于硬件的任务;An operating system 3051, including various system programs for implementing various basic services and processing hardware-based tasks;
应用程序3052,包含目标网络数据的数据分块参数的设置程序、目标数据块的划分程序、目标数据块与数据库中的数据块的比较程序以及目标数据块的删除程序等各种应用程序,用于实现各种应用业务。The application 3052 includes various setting programs of a data block parameter setting program of the target network data, a partitioning program of the target data block, a comparison program of the target data block and the data block in the database, and a deletion program of the target data block, and the like. To achieve a variety of application services.
具体地,处理器301用于调用存储器305中存储的程序,执行以下操作:
Specifically, the processor 301 is configured to invoke a program stored in the memory 305 to perform the following operations:
接收接口调用指令,所述接口调用指令携带有加载客户端脚本需要调用的接口对应的接口标识和参数;Receiving an interface call instruction, where the interface call instruction carries an interface identifier and a parameter corresponding to an interface that is required to be loaded by the client script;
当浏览器中当前运行的浏览器内核不是所述客户端脚本对应的目标浏览器内核,且所述当前运行的浏览器内核提供的与所述接口标识对应的第一接口函数和所述目标浏览器内核提供的与所述接口标识对应的第二接口函数存在差异时,获取预设的所述接口标识对应的所述当前运行的浏览器内核的目标接口函数,所述目标接口函数为根据所述目标浏览器内核提供的所述第二接口函数进行预设的与所述当前运行的浏览器内核对应的第三接口函数;When the browser kernel currently running in the browser is not the target browser kernel corresponding to the client script, and the first interface function corresponding to the interface identifier provided by the currently running browser kernel and the target browsing Obtaining a target interface function of the currently running browser kernel corresponding to the preset interface identifier, where the second interface function corresponding to the interface identifier is different, and the target interface function is The second interface function provided by the target browser kernel performs a preset third interface function corresponding to the currently running browser kernel;
将所述参数作为所述目标接口函数的输入参数,调用所述目标接口函数。The target interface function is invoked by using the parameter as an input parameter of the target interface function.
在另一种实施例中,所述客户端脚本为所述浏览器中的扩展插件所包括的脚本程序,处理器301执行所述接收接口调用指令,所述接口调用指令携带有加载客户端脚本需要调用的接口对应的接口标识和参数的操作之前,还执行以下操作:In another embodiment, the client script is a script program included in an extension in the browser, and the processor 301 executes the receiving interface call instruction, where the interface call instruction carries a load client script. Before performing the operation of the interface identifier and parameters corresponding to the interface to be invoked, the following operations are also performed:
当检测到打开网页的触发事件时,将浏览器中需要加载的扩展插件对应的客户端脚本插入待打开的网页中。When the trigger event of opening the webpage is detected, the client script corresponding to the extension that needs to be loaded in the browser is inserted into the webpage to be opened.
在另一种实施例中,所述扩展插件还包括在浏览器中加载的主程序,处理器301执行所述接收接口调用指令,所述接口调用指令携带有加载客户端脚本需要调用的接口对应的接口标识和参数的操作之前,还执行以下操作:In another embodiment, the extension further includes a main program loaded in a browser, and the processor 301 executes the receiving interface calling instruction, where the interface calling instruction carries an interface corresponding to the calling client script to be called. Before the operation of the interface identifier and parameters, the following operations are also performed:
接收到加载该扩展插件的触发指令时,启动新的进程加载所述主程序,所述新的进程中加载有所述目标浏览器内核。Upon receiving the trigger instruction to load the extension, a new process is started to load the main program, and the target browser kernel is loaded in the new process.
在另一种实施例中,处理器301执行所述当浏览器中当前运行的浏览器内核不是所述客户端脚本对应的目标浏览器内核,且所述当前运行的浏览器内核提供的与所述接口标识对应的第一接口函数和所述目标浏览器内核提供的与所述接口标识对应的第二接口函数存在差异时,获取预设的所述接口标识对应的所述当前运行的浏览器内核的目标接口函数的操作,包括执行以下操作:In another embodiment, the processor 301 performs: when the browser kernel currently running in the browser is not the target browser kernel corresponding to the client script, and the currently running browser kernel provides the same When the first interface function corresponding to the interface identifier is different from the second interface function corresponding to the interface identifier provided by the target browser kernel, the currently running browser corresponding to the preset interface identifier is obtained. The operation of the kernel's target interface function, including the following:
当浏览器中当前运行的浏览器内核不是所述客户端脚本对应的目标浏览器内核,且所述当前运行的浏览器内核提供的与所述接口标识对应的第一接口函数和所述目标浏览器内核提供的与所述接口标识对应的第二接口函数存在差异时,根据所述接口标识,从预设信息库中查询该接口标识对应所述当前运行的浏览器内核的接口函数;When the browser kernel currently running in the browser is not the target browser kernel corresponding to the client script, and the first interface function corresponding to the interface identifier provided by the currently running browser kernel and the target browsing When there is a difference between the second interface function corresponding to the interface identifier provided by the kernel, the interface identifier is queried from the preset information base according to the interface function of the currently running browser kernel;
将所查询到的接口函数确定为目标接口函数。Determine the interface function that is queried as the target interface function.
在另一种实施例中,处理器301执行所述将所述参数作为所述目标接口函数的输入参数,调用所述目标接口函数的操作之后,还包括执行以下操作:In another embodiment, the processor 301 performs the input parameter that uses the parameter as the target interface function. After the operation of the target interface function is invoked, the method further includes:
返回所述目标接口函数的调用结果。
Returns the result of the call to the target interface function.
在本发明实施例描述的技术方案中,接收接口调用指令,所述接口调用指令携带有加载客户端脚本需要调用的接口对应的接口标识和参数;当浏览器中当前运行的浏览器内核不是所述客户端脚本对应的目标浏览器内核,且所述当前运行的浏览器内核提供的与所述接口标识对应的第一接口函数和所述目标浏览器内核提供的与所述接口标识对应的第二接口函数存在差异时,获取预设的所述接口标识对应的所述当前运行的浏览器内核的目标接口函数;将所述参数作为所述目标接口函数的输入参数,调用所述目标接口函数。采用本发明实施例,根据浏览器中不同的浏览器内核针对某些接口提供的接口函数存在差异的情况,预先设置可供替换的接口函数,因此,不管当前运行的浏览器内核是不是客户端脚本对应的目标浏览器内核,浏览器均可以正常执行客户端脚本调用该部分差异接口的请求,从而,避免客户端脚本因调用这部分差异接口时而出现运行错误的情况,提升浏览器的兼容性。In the technical solution described in the embodiment of the present invention, an interface call instruction is received, where the interface call instruction carries an interface identifier and a parameter corresponding to an interface that is required to be loaded by the client script; when the browser kernel currently running in the browser is not a target browser kernel corresponding to the client script, and the first interface function corresponding to the interface identifier provided by the currently running browser kernel and the first interface corresponding to the interface identifier provided by the target browser kernel When there is a difference between the two interface functions, obtaining a target interface function of the currently running browser kernel corresponding to the preset interface identifier; using the parameter as an input parameter of the target interface function, calling the target interface function . According to the embodiment of the present invention, according to different browser kernels in the browser, the interface functions provided by some interfaces are different, and the interface functions that can be replaced are preset, so that whether the currently running browser kernel is a client or not The target browser kernel corresponding to the script, the browser can normally execute the client script to call the request of the partial difference interface, thereby avoiding the running error of the client script when calling the part of the difference interface, and improving the compatibility of the browser. .
在本说明书的描述中,参考术语“一个实施例”、“一些实施例”、“示例”、“具体示例”、或“一些示例”等的描述意指结合该实施例或示例描述的具体特征、结构、材料或者特点包含于本发明的至少一个实施例或示例中。在本说明书中,对上述术语的示意性表述不一定是必须针对相同的实施例或示例。而且,描述的具体特征、结构、材料或者特点可以在任一个或多个实施例或示例中以合适的方式结合。此外,在不相互矛盾的情况下,本领域的技术人员可以将本说明书中描述的不同实施例或示例以及不同实施例或示例的特征进行结合和组合。In the description of the present specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" and the like means a specific feature described in connection with the embodiment or example. A structure, material or feature is included in at least one embodiment or example of the invention. In the present specification, the schematic representation of the above terms does not necessarily have to be for the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in a suitable manner in any one or more embodiments or examples. In addition, various embodiments or examples described in the specification, as well as features of various embodiments or examples, may be combined and combined.
本领域的技术人员可以将本说明书中描述的不同实施例以及不同实施例的特征进行结合和组合。本发明所有实施例中的模块或单元,可以通过通用集成电路,例如CPU(Central Processing Unit,中央处理器),或通过ASIC(Application Specific Integrated Circuit,专用集成电路)来实现。Those skilled in the art can combine and combine the different embodiments described in the specification and the features of the different embodiments. The modules or units in all the embodiments of the present invention may be implemented by a general-purpose integrated circuit, such as a CPU (Central Processing Unit) or an ASIC (Application Specific Integrated Circuit).
本发明所有实施例方法中的步骤可以根据实际需要进行顺序调整、合并和删减;本发明所有实施例装置中的模块或单元可以根据实际需要进行合并、划分和删减。The steps in the method of all the embodiments of the present invention may be sequentially adjusted, combined, and deleted according to actual needs; the modules or units in all the embodiments of the present invention may be combined, divided, and deleted according to actual needs.
流程图中或在此以其他方式描述的任何过程或方法描述可以被理解为,表示包括一个或更多个用于实现特定逻辑功能或过程的步骤的可执行指令的代码的模块、片段或部分,并且本发明的优选实施方式的范围包括另外的实现,其中可以不按所示出或讨论的顺序,包括根据所涉及的功能按基本同时的方式或按相反的顺序,来执行功能,这应被本发明的实施例所属技术领域的技术人员所理解。Any process or method description in the flowcharts or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a particular logical function or process. And the scope of the preferred embodiments of the invention includes additional implementations, in which the functions may be performed in a substantially simultaneous manner or in an opposite order depending on the functions involved, in the order shown or discussed. It will be understood by those skilled in the art to which the embodiments of the present invention pertain.
在流程图中表示或在此以其他方式描述的逻辑和/或步骤,例如,可以被认为是用于实现逻辑功能的可执行指令的定序列表,可以具体实现在任何计算机可读介质中,以供指令执
行系统、装置或设备(如基于计算机的系统、包括处理器的系统或其他可以从指令执行系统、装置或设备取指令并执行指令的系统)使用,或结合这些指令执行系统、装置或设备而使用。就本说明书而言,"计算机可读介质"可以是任何可以包含、存储、通信、传播或传输程序以供指令执行系统、装置或设备或结合这些指令执行系统、装置或设备而使用的装置。计算机可读介质的更具体的示例(非穷尽性列表)包括以下:具有一个或多个布线的电连接部(电子装置),便携式计算机盘盒(磁装置),随机存取存储器(RAM),只读存储器(ROM),可擦除可编辑只读存储器(EPROM或闪速存储器),光纤装置,以及便携式光盘只读存储器(CDROM)。另外,计算机可读介质甚至可以是可在其上打印所述程序的纸或其他合适的介质,因为可以例如通过对纸或其他介质进行光学扫描,接着进行编辑、解译或必要时以其他合适方式进行处理来以电子方式获得所述程序,然后将其存储在计算机存储器中。The logic and/or steps represented in the flowchart or otherwise described herein, for example, may be considered as an ordered list of executable instructions for implementing logical functions, and may be embodied in any computer readable medium, For instruction
A system, apparatus, or device (such as a computer-based system, a system including a processor, or other system that can fetch instructions and execute instructions from an instruction execution system, apparatus, or device), or in conjunction with such instructions to execute a system, apparatus, or device. use. For the purposes of this specification, a "computer-readable medium" can be any apparatus that can contain, store, communicate, propagate, or transport a program for use in an instruction execution system, apparatus, or device, or in conjunction with the instruction execution system, apparatus, or device. More specific examples (non-exhaustive list) of computer readable media include the following: electrical connections (electronic devices) having one or more wires, portable computer disk cartridges (magnetic devices), random access memory (RAM), Read only memory (ROM), erasable editable read only memory (EPROM or flash memory), fiber optic devices, and portable compact disk read only memory (CDROM). In addition, the computer readable medium may even be a paper or other suitable medium on which the program can be printed, as it may be optically scanned, for example by paper or other medium, followed by editing, interpretation or, if appropriate, other suitable The method is processed to obtain the program electronically and then stored in computer memory.
本技术领域的普通技术人员可以理解实现上述实施例方法携带的全部或部分步骤是可以通过程序来指令相关的硬件完成,所述的程序可以存储于一种计算机可读存储介质中,该程序在执行时,包括方法实施例的步骤之一或其组合。One of ordinary skill in the art can understand that all or part of the steps carried by the method of implementing the above embodiments can be completed by a program to instruct related hardware, and the program can be stored in a computer readable storage medium. When executed, one or a combination of the steps of the method embodiments is included.
此外,在本发明各个实施例中的各功能单元可以集成在一个处理模块中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。所述集成的模块如果以软件功能模块的形式实现并作为独立的产品销售或使用时,也可以存储在一个计算机可读取存储介质中。In addition, each functional unit in each embodiment of the present invention may be integrated into one processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above integrated modules can be implemented in the form of hardware or in the form of software functional modules. The integrated modules, if implemented in the form of software functional modules and sold or used as stand-alone products, may also be stored in a computer readable storage medium.
上述提到的存储介质可以是只读存储器,磁盘或光盘等。尽管上面已经示出和描述了本发明的实施例,可以理解的是,上述实施例是示例性的,不能理解为对本发明的限制,本领域的普通技术人员在本发明的范围内可以对上述实施例进行变化、修改、替换和变型。The above mentioned storage medium may be a read only memory, a magnetic disk or an optical disk or the like. Although the embodiments of the present invention have been shown and described, it is understood that the above-described embodiments are illustrative and are not to be construed as limiting the scope of the invention. The embodiments are subject to variations, modifications, substitutions and variations.
以上所揭露的仅为本发明的较佳实施例而已,当然不能以此来限定本发明之权利范围,本领域普通技术人员可以理解实现上述实施例的全部或部分流程,并依本发明权利要求所作的等同变化,仍属于发明所涵盖的范围。
The above is only the preferred embodiment of the present invention, and the scope of the present invention is not limited thereto, and those skilled in the art can understand all or part of the process of implementing the above embodiments, and according to the claims of the present invention. Equivalent changes made are still within the scope of the invention.
Claims (14)
- 一种接口调用方法,其特征在于,包括:An interface calling method, comprising:接收接口调用指令,所述接口调用指令携带有加载客户端脚本需要调用的接口对应的接口标识和参数;Receiving an interface call instruction, where the interface call instruction carries an interface identifier and a parameter corresponding to an interface that is required to be loaded by the client script;当浏览器中当前运行的浏览器内核不是所述客户端脚本对应的目标浏览器内核,且所述当前运行的浏览器内核提供的与所述接口标识对应的第一接口函数和所述目标浏览器内核提供的与所述接口标识对应的第二接口函数存在差异时,获取预设的所述接口标识对应的所述当前运行的浏览器内核的目标接口函数,所述目标接口函数为根据所述目标浏览器内核提供的所述第二接口函数进行预设的与所述当前运行的浏览器内核对应的第三接口函数;When the browser kernel currently running in the browser is not the target browser kernel corresponding to the client script, and the first interface function corresponding to the interface identifier provided by the currently running browser kernel and the target browsing Obtaining a target interface function of the currently running browser kernel corresponding to the preset interface identifier, where the second interface function corresponding to the interface identifier is different, and the target interface function is The second interface function provided by the target browser kernel performs a preset third interface function corresponding to the currently running browser kernel;将所述参数作为所述目标接口函数的输入参数,调用所述目标接口函数。The target interface function is invoked by using the parameter as an input parameter of the target interface function.
- 如权利要求1所述的方法,其特征在于,所述客户端脚本为所述浏览器中的扩展插件所包括的脚本程序;The method of claim 1, wherein the client script is a script program included in an extension in the browser;在所述接收接口调用指令之前,所述方法还包括:Before the receiving interface calls the instruction, the method further includes:当检测到打开网页的触发事件时,将浏览器中需要加载的扩展插件对应的客户端脚本插入待打开的网页中。When the trigger event of opening the webpage is detected, the client script corresponding to the extension that needs to be loaded in the browser is inserted into the webpage to be opened.
- 如权利要求2所述的方法,其特征在于,所述扩展插件还包括在浏览器中加载的主程序;The method of claim 2, wherein the extension further comprises a main program loaded in a browser;所述接收接口调用指令之前,所述方法还包括:Before the receiving interface calls the instruction, the method further includes:接收到加载所述扩展插件的触发指令时,启动新的进程加载所述主程序,所述新的进程中加载有所述目标浏览器内核。Upon receiving the trigger instruction to load the extension, a new process is started to load the main program, and the target browser kernel is loaded in the new process.
- 如权利要求1至3中任一项所述的方法,其特征在于,所述当浏览器中当前运行的浏览器内核不是所述客户端脚本对应的目标浏览器内核,且所述当前运行的浏览器内核提供的与所述接口标识对应的第一接口函数和所述目标浏览器内核提供的与所述接口标识对应的第二接口函数存在差异时,获取预设的所述接口标识对应的所述当前运行的浏览器内核的目标接口函数包括:The method according to any one of claims 1 to 3, wherein the browser kernel currently running in the browser is not the target browser kernel corresponding to the client script, and the currently running browser Obtaining, by the browser kernel, a first interface function corresponding to the interface identifier and a second interface function corresponding to the interface identifier provided by the target browser kernel, obtaining a preset corresponding to the interface identifier The target interface function of the currently running browser kernel includes:当浏览器中当前运行的浏览器内核不是所述客户端脚本对应的目标浏览器内核,且所述当前运行的浏览器内核提供的与所述接口标识对应的第一接口函数和所述目标浏览器内核 提供的与所述接口标识对应的第二接口函数存在差异时,根据所述接口标识,从预设信息库中查询所述接口标识对应所述当前运行的浏览器内核的接口函数;When the browser kernel currently running in the browser is not the target browser kernel corresponding to the client script, and the first interface function corresponding to the interface identifier provided by the currently running browser kernel and the target browsing Kernel When the second interface function corresponding to the interface identifier is different, querying, according to the interface identifier, the interface identifier corresponding to the interface function of the currently running browser kernel from the preset information base;将所查询到的接口函数确定为目标接口函数。Determine the interface function that is queried as the target interface function.
- 如权利要求1-4中任一项所述的方法,其特征在于,所述将所述参数作为所述目标接口函数的输入参数,调用所述目标接口函数之后,所述方法还包括:The method according to any one of claims 1-4, wherein the method further comprises: after the parameter is used as an input parameter of the target interface function, after the target interface function is invoked, the method further comprises:返回所述目标接口函数的调用结果。Returns the result of the call to the target interface function.
- 一种接口调用装置,所述装置应用于浏览器中,其特征在于,包括:An interface calling device, the device being applied to a browser, comprising:接收模块,用于接收接口调用指令,所述接口调用指令携带有加载客户端脚本需要调用的接口对应的接口标识和参数;a receiving module, configured to receive an interface call instruction, where the interface call instruction carries an interface identifier and a parameter corresponding to an interface that is required to be loaded by the client script;确定模块,用于当浏览器中当前运行的浏览器内核不是所述客户端脚本对应的目标浏览器内核,且所述当前运行的浏览器内核提供的与所述接口标识对应的第一接口函数和所述目标浏览器内核提供的与所述接口标识对应的第二接口函数存在差异时,获取预设的所述接口标识对应的所述当前运行的浏览器内核的目标接口函数,所述目标接口函数为根据所述目标浏览器内核提供的所述第二接口函数进行预设的与所述当前运行的浏览器内核对应的第三接口函数;a determining module, configured to: when the currently running browser kernel in the browser is not the target browser kernel corresponding to the client script, and the first interface function corresponding to the interface identifier provided by the currently running browser kernel Obtaining, by the target browser kernel, a second interface function corresponding to the interface identifier, acquiring a target interface function of the currently running browser kernel corresponding to the preset interface identifier, where the target The interface function is a third interface function corresponding to the currently running browser kernel according to the second interface function provided by the target browser kernel;调用模块,用于将所述参数作为所述目标接口函数的输入参数,调用所述目标接口函数。The calling module is configured to invoke the parameter as the input parameter of the target interface function, and invoke the target interface function.
- 如权利要求6所述的装置,其特征在于,所述客户端脚本为所述浏览器中的扩展插件所包括的脚本程序,所述装置还包括:The device according to claim 6, wherein the client script is a script program included in the extension in the browser, the device further comprising:插入模块,用于当检测到打开网页的触发事件时,将浏览器中需要加载的扩展插件对应的客户端脚本插入待打开的网页中。The inserting module is configured to insert a client script corresponding to the extension that needs to be loaded in the browser into the webpage to be opened when the triggering event of opening the webpage is detected.
- 如权利要求7所述的装置,其特征在于,所述扩展插件还包括在浏览器中加载的主程序,所述装置还包括:The device of claim 7, wherein the extension further comprises a main program loaded in a browser, the device further comprising:启动模块,用于接收到加载所述扩展插件的触发指令时,启动新的进程加载所述主程序,所述新的进程中加载有所述目标浏览器内核。The startup module is configured to start a new process to load the main program when the trigger instruction for loading the extension is received, and the target browser kernel is loaded in the new process.
- 如权利要求6至8中任一项所述的装置,其特征在于,所述确定模块具体用于:The device according to any one of claims 6 to 8, wherein the determining module is specifically configured to:当浏览器中当前运行的浏览器内核不是所述客户端脚本对应的目标浏览器内核,且所述 当前运行的浏览器内核提供的与所述接口标识对应的第一接口函数和所述目标浏览器内核提供的与所述接口标识对应的第二接口函数存在差异时,根据所述接口标识,从预设信息库中查询该接口标识对应所述当前运行的浏览器内核的接口函数;When the browser kernel currently running in the browser is not the target browser kernel corresponding to the client script, and the When the first interface function corresponding to the interface identifier provided by the currently running browser kernel is different from the second interface function provided by the target browser kernel and corresponding to the interface identifier, according to the interface identifier, Querying, in the preset information base, the interface identifier corresponding to the interface function of the currently running browser kernel;将所查询到的接口函数确定为目标接口函数。Determine the interface function that is queried as the target interface function.
- 如权利要求6-9任一项所述的装置,其特征在于,所述装置还包括:The device of any of claims 6-9, wherein the device further comprises:返回模块,用于返回所述目标接口函数的调用结果。A return module for returning a result of the call of the target interface function.
- 一种终端,其特征在于,包括如权利要求6-10任一项所述的接口调用装置。A terminal characterized by comprising the interface calling device according to any one of claims 6-10.
- 一种终端,包括:A terminal comprising:处理器;processor;存储器,用于存储所述处理器可执行的指令;a memory for storing instructions executable by the processor;所述处理器用于:The processor is used to:接收接口调用指令,所述接口调用指令携带有加载客户端脚本需要调用的接口对应的接口标识和参数;Receiving an interface call instruction, where the interface call instruction carries an interface identifier and a parameter corresponding to an interface that is required to be loaded by the client script;当浏览器中当前运行的浏览器内核不是所述客户端脚本对应的目标浏览器内核,且所述当前运行的浏览器内核提供的与所述接口标识对应的第一接口函数和所述目标浏览器内核提供的与所述接口标识对应的第二接口函数存在差异时,获取预设的所述接口标识对应的所述当前运行的浏览器内核的目标接口函数,所述目标接口函数为根据所述目标浏览器内核提供的所述第二接口函数进行预设的与所述当前运行的浏览器内核对应的第三接口函数;When the browser kernel currently running in the browser is not the target browser kernel corresponding to the client script, and the first interface function corresponding to the interface identifier provided by the currently running browser kernel and the target browsing Obtaining a target interface function of the currently running browser kernel corresponding to the preset interface identifier, where the second interface function corresponding to the interface identifier is different, and the target interface function is The second interface function provided by the target browser kernel performs a preset third interface function corresponding to the currently running browser kernel;将所述参数作为所述目标接口函数的输入参数,调用所述目标接口函数。The target interface function is invoked by using the parameter as an input parameter of the target interface function.
- 一种计算机可读存储介质,具有存储于其中的指令,当终端的处理器执行所述指令时,所述终端执行如权利要求1-5中任一项所述的接口调用方法。A computer readable storage medium having instructions stored therein, the terminal executing the interface calling method of any one of claims 1-5 when the processor of the terminal executes the instructions.
- 一种计算机程序,当其在处理器上运行时,执行如权利要求1-5中任一项所述的接口调用方法。 A computer program that, when run on a processor, performs the interface invocation method of any one of claims 1-5.
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510229507.9 | 2015-05-07 | ||
CN201510229507.9A CN104881318B (en) | 2015-05-07 | 2015-05-07 | A kind of interface call method, device and terminal |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2016177341A1 true WO2016177341A1 (en) | 2016-11-10 |
Family
ID=53948824
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2016/081184 WO2016177341A1 (en) | 2015-05-07 | 2016-05-05 | Interface calling method and device, and terminal |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN104881318B (en) |
WO (1) | WO2016177341A1 (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110333914A (en) * | 2019-04-12 | 2019-10-15 | 上海连尚网络科技有限公司 | A method and device for performing target operations |
CN113961366A (en) * | 2020-07-20 | 2022-01-21 | 华为技术有限公司 | Kernel function calling method of operating system and computer equipment |
CN115086393A (en) * | 2022-06-13 | 2022-09-20 | 卫宁健康科技集团股份有限公司 | Interface calling method, device, equipment and storage medium |
Families Citing this family (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104881318B (en) * | 2015-05-07 | 2019-06-25 | 珠海豹趣科技有限公司 | A kind of interface call method, device and terminal |
CN107632848B (en) * | 2016-07-13 | 2020-02-07 | 腾讯科技(深圳)有限公司 | Data processing method and device |
CN106708967B (en) * | 2016-11-30 | 2020-06-02 | 北京小米移动软件有限公司 | Page display method and device |
CN107301137A (en) * | 2017-07-04 | 2017-10-27 | 福建中金在线信息科技有限公司 | RSET interface realizing methods and device and electronic equipment and computer-readable recording medium |
CN107977243A (en) * | 2017-11-27 | 2018-05-01 | 海尔优家智能科技(北京)有限公司 | A kind of third party's interface call method and device |
CN109032612B (en) * | 2018-07-02 | 2022-01-28 | 平安科技(深圳)有限公司 | Interface calling method and device of hybrid application and computer readable storage medium |
CN109976756B (en) * | 2019-03-11 | 2022-11-11 | 宸瑞普惠(广州)科技有限公司 | Processing method and system for consistency of UI display effect |
CN112181406B (en) * | 2019-06-14 | 2024-12-17 | 北京搜狗科技发展有限公司 | Sharing method and device of rendering engine |
CN110442400B (en) * | 2019-08-15 | 2023-04-18 | 网易(杭州)网络有限公司 | Browser control method and device |
CN110688180B (en) * | 2019-09-03 | 2021-05-11 | 华云数据控股集团有限公司 | Front-end system, front-end data flow control method, electronic device and storage medium |
CN112214712A (en) * | 2020-10-28 | 2021-01-12 | 新华三大数据技术有限公司 | Automatic browser switching method and device, storage medium and electronic equipment |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103019817A (en) * | 2012-11-30 | 2013-04-03 | 北京奇虎科技有限公司 | Method and device for page interaction |
CN103176834A (en) * | 2011-12-26 | 2013-06-26 | 腾讯科技(深圳)有限公司 | Method and device for calling expansion interface |
CN104281455A (en) * | 2014-10-11 | 2015-01-14 | 北京金山安全软件有限公司 | Interface calling method and device and terminal |
WO2015021860A1 (en) * | 2013-08-15 | 2015-02-19 | Tencent Technology (Shenzhen) Company Limited | Method and apparatus for loading rendering engine |
CN104881318A (en) * | 2015-05-07 | 2015-09-02 | 北京金山安全软件有限公司 | Interface calling method and device and terminal |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20020055981A1 (en) * | 2000-08-31 | 2002-05-09 | Frederic Spaey | System and method for remotely browsing structured data |
US7748609B2 (en) * | 2007-08-31 | 2010-07-06 | Gemalto Inc. | System and method for browser based access to smart cards |
CN103226474B (en) * | 2013-05-10 | 2016-09-28 | 北京奇虎科技有限公司 | Exchange method between page script and browser program, Apparatus and system |
-
2015
- 2015-05-07 CN CN201510229507.9A patent/CN104881318B/en active Active
-
2016
- 2016-05-05 WO PCT/CN2016/081184 patent/WO2016177341A1/en active Application Filing
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103176834A (en) * | 2011-12-26 | 2013-06-26 | 腾讯科技(深圳)有限公司 | Method and device for calling expansion interface |
CN103019817A (en) * | 2012-11-30 | 2013-04-03 | 北京奇虎科技有限公司 | Method and device for page interaction |
WO2015021860A1 (en) * | 2013-08-15 | 2015-02-19 | Tencent Technology (Shenzhen) Company Limited | Method and apparatus for loading rendering engine |
CN104281455A (en) * | 2014-10-11 | 2015-01-14 | 北京金山安全软件有限公司 | Interface calling method and device and terminal |
CN104881318A (en) * | 2015-05-07 | 2015-09-02 | 北京金山安全软件有限公司 | Interface calling method and device and terminal |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110333914A (en) * | 2019-04-12 | 2019-10-15 | 上海连尚网络科技有限公司 | A method and device for performing target operations |
CN110333914B (en) * | 2019-04-12 | 2023-09-15 | 上海连尚网络科技有限公司 | A method and device for performing target operations |
CN113961366A (en) * | 2020-07-20 | 2022-01-21 | 华为技术有限公司 | Kernel function calling method of operating system and computer equipment |
CN115086393A (en) * | 2022-06-13 | 2022-09-20 | 卫宁健康科技集团股份有限公司 | Interface calling method, device, equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN104881318B (en) | 2019-06-25 |
CN104881318A (en) | 2015-09-02 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2016177341A1 (en) | Interface calling method and device, and terminal | |
EP3876116B1 (en) | Method and apparatus for running mini program, electronic device, and storage medium | |
US10325009B2 (en) | Method and apparatus for using custom component parsing engine to parse tag of custom component | |
WO2016192556A1 (en) | Interface invoking method, device and terminal | |
CN107861713B (en) | Data calling method and device and computer readable storage medium | |
KR102220127B1 (en) | Method and apparatus for customized software development kit (sdk) generation | |
US10176270B2 (en) | Performance of template based javascript widgets | |
US20100218106A1 (en) | Automatically Selecting Internet Browser and Providing Web Page Service | |
TW201732647A (en) | Webpage script loading method and device | |
US8539506B2 (en) | Dynamic injection of code into running process | |
US20140108914A1 (en) | Webpages with onboard hardware functions | |
CN110221968A (en) | Method for testing software and Related product | |
US20220030052A1 (en) | Cross-platform Module for Loading Across a Plurality of Device Types | |
CN108647032A (en) | Using loading method and device, computer installation and computer readable storage medium | |
CN111767109A (en) | H5 page display method, device and readable storage medium based on terminal application | |
US20130081010A1 (en) | Template and server content download using protocol handlers | |
CN116523457A (en) | Workflow processing method, device, equipment and storage medium based on business process | |
CN111177624A (en) | Website front-back end communication method and device, computer equipment and storage medium | |
CN112882698A (en) | Development environment generation method and device, computer storage medium and electronic device | |
US20130151945A1 (en) | Processing Published and Subscribed Events | |
CN114254232B (en) | Cloud product page generation method, device, computer equipment and storage medium | |
CN115525305A (en) | Data processing method, application starting method, device, computer equipment and storage medium | |
CN112612531A (en) | Application program starting method and device, electronic equipment and storage medium | |
CN110262841B (en) | Method and device for enhancing byte codes | |
CN107092601B (en) | Resource file construction method, resource file application method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 16789335 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
32PN | Ep: public notification in the ep bulletin as address of the adressee cannot be established |
Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 21/02/2018) |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 16789335 Country of ref document: EP Kind code of ref document: A1 |