Detailed Description
The principles and spirit of the present application will be described below with reference to several exemplary embodiments. It should be understood that these embodiments are presented merely to enable one skilled in the art to better understand and practice the present application and are not intended to limit the scope of the present application in any way. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
Those skilled in the art will appreciate that embodiments of the present application may be implemented as a system, apparatus, device, method, or computer program product. Accordingly, the present disclosure may be embodied in the following forms, namely: complete hardware, complete software (including firmware, resident software, micro-code, etc.), or a combination of hardware and software.
In this document, it should be understood that any number of elements in the drawings is for illustration and not limitation, and that any naming is used only for distinction and not for any limitation.
The principles and spirit of the present application are explained in detail below with reference to several representative embodiments thereof.
Summary of The Invention
The inventors of the present application have found that, in general, the order and distribution of the pages belonging to different websites that are opened by a user are disordered, for example, referring to fig. 1, the pages of the same website may be distributed in different browser windows, or the pages of different websites may be alternately arranged in the same browser window. The "close other pages" button and the "close right pages" button in the browser window cannot distinguish the pages of different websites, and only all pages except the current page or the pages to the right of the current page can be closed. Therefore, under the above situation, when the user needs to close all pages of a certain website, the user still needs to manually close one by one, and the operation is complicated.
To solve the above problems, the present inventors have considered that when a user opens a page in a browser, a page controller is created for a plurality of associated pages, connections between the plurality of associated pages and the page controller are respectively established, and a page close control of the page controller can be displayed on each associated page, so that the user can quickly close the plurality of associated pages by clicking the page close control in any of the associated pages. The specific multi-page control method comprises the following steps: and responding to the triggering operation of the multi-page closing control on the current page, calling the multi-page controller connected with the current page, and sending a closing instruction to the page connected with the multi-page controller through the multi-page controller so as to close the page connected with the multi-page controller.
Having described the basic principles of the present application, various non-limiting embodiments of the present application are specifically described below.
Application scene overview
Referring to fig. 2, an application scenario schematic diagram of a multi-page control method provided in an embodiment of the present application is shown. The application scene comprises a terminal device 201 and a background server 202, wherein the terminal device 201 and the background server 202 are connected through a communication network. Terminal device 201 includes, but is not limited to, desktop computers, mobile phones, mobile computers, tablet computers, media players, smart wearable devices, smart televisions, and like electronic devices. The background server 202 may be a server, a server cluster formed by a plurality of servers, or a cloud computing center. The background server 202 is a server that can provide a web browsing server to the terminal device 201. The terminal device 201 is provided with a browser, a user can initiate a webpage acquisition request to the background server 202 through the browser, the background server 202 feeds back the responsive webpage content to the terminal device 201, and the terminal device 201 displays the received webpage content.
Exemplary method
The multi-page control method according to the exemplary embodiments of the present application will be described below in conjunction with the above application scenario. It should be noted that the above application scenario is only shown for the convenience of understanding the spirit and principles of the present application, and embodiments of the present application are not limited in any way in this respect. Rather, embodiments of the present application may be applied to any scenario where applicable.
Referring to fig. 3, the multi-page control method provided in the embodiment of the present application may be applied to the terminal device 201 shown in fig. 2, and specifically may include the following steps:
s301, responding to triggering operation of the multi-page closing control on the current page.
In particular implementations, the triggering operation includes, but is not limited to, clicking, long press multi-page closing control, and the like. Each page with which the multi-page controller has established a connection displays a corresponding multi-page close control, and the multi-page controller can be used for monitoring and responding to trigger events (including clicking events, long-press events and the like) for the multi-page close control generated in any page with which the multi-page controller has established a connection.
In particular implementations, a user may open one or more browser windows through a browser, and each browser window may contain one or more pages therein. The current page refers to a page currently browsed by the user.
S302, calling a multi-page controller connected with the current page, and sending a closing instruction to the page connected with the multi-page controller through the multi-page controller so as to close the page connected with the multi-page controller, wherein all the pages connected with the multi-page controller are associated.
Wherein all pages associated with establishing a connection with the multi-page controller belong to the same website. In the implementation, a corresponding multi-page controller can be built for each website, all pages which are opened by a user and belong to a certain website are connected with the multi-page controller corresponding to the website, and the multi-page controller can uniformly broadcast information to all pages connected with the multi-page controller. In addition, a multi-page closing control corresponding to the multi-page controller connected with the page is displayed in each page. The user can trigger the corresponding multi-page controller to send a closing instruction to all pages connected with the multi-page controller by clicking the multi-page closing control so as to close the pages connected with the multi-page controller.
Referring to fig. 4, the user opens 4 pages P belonging to the website a through the browser A1 、P A2 、P A3 And P A4 Also open 3 pages P belonging to website B B1 、P B2 And P B3 The browser establishes a multi-page controller C for website A 1 Respectively page P A1 、P A2 、P A3 And P A4 Build and Multi-Page controller C 1 Connection between each other and respectively at page P A1 、P A2 、P A3 And P A4 Corresponding position in (a) shows the multi-page controller C 1 A corresponding multi-page close control 401; simultaneously, a multi-page controller C is established for the website B 2 Respectively page P B1 、P B2 And P B3 Build and Multi-Page controller C 2 Connection between each other and respectively at page P B1 、P B2 And P B3 Corresponding position in (a) shows the multi-page controller C 2 A corresponding multi-page close control 402. Suppose that the user is currently browsing page P A3 And wants to close all pages of website a (including page P A1 、P A2 、P A3 And P A4 ) The user can click on page P A3 The multi-page close control 401 displayed above triggers the multi-page controller C within the browser 1 To page P A1 、P A2 、P A3 And P A4 Send close command, page P A1 、P A2 、P A3 And P A4 And executing the action of closing the page after receiving the closing instruction. Thus, the user can quickly close all pages belonging to the website A through the multi-page closing control, and keep pages belonging to the website B.
According to the multi-page control method provided by the embodiment of the application, a user can rapidly close the pages belonging to a certain website under the condition of opening a plurality of pages of a plurality of websites, so that tedious and repeated closing actions one by one are avoided, the cost of repeated operation of the user is reduced, the time is saved, and the user experience is improved.
In particular, to meet more operational demands of users, the multi-page close control includes closing all page controls and closing other page controls. And closing all page controls to close all pages connected with the corresponding multi-page controller, and closing other page controls to close other pages except the current page in all pages connected with the corresponding multi-page controller.
For this purpose, in one possible implementation manner, the multi-page control method of the embodiment of the present application further includes the following steps: after the current page receives the closing instruction, if the triggering operation is determined to be aimed at closing all page controls, closing the current page; if the trigger operation is determined to be aimed at closing other page controls, the current page is not closed.
Taking fig. 5 as an example, the multi-page control method in the above embodiment is specifically described. The other pages shown in fig. 5 are pages associated with the current page. After clicking the multi-page closing control in the current page, the user responds to the triggering operation of the multi-page closing control on the current page, calls the multi-page controller connected with the current page, and sends a closing instruction to the page connected with the called multi-page controller. After the current page receives the closing instruction sent by the multi-page controller, judging whether the multi-page closing control aimed at by the triggering operation is a closing control of all the pages, if so, executing the closing instruction to close the current page, and if not, not closing the current page. And after receiving the closing instruction sent by the multi-page controller, the other pages execute the closing instruction to close the pages respectively.
When the multi-page closing control aimed at by the triggering operation is a closing command, the closing command sent by the multi-page controller is a first closing command; when the multi-page closing control aimed at by the triggering operation is the closing of other page controls, the closing instruction sent by the multi-page controller is a second closing instruction. In this way, the current page can judge whether the multi-page closing control aimed at by the triggering operation is to close all page controls by judging whether the first closing instruction or the second closing instruction is received.
In specific implementation, the current page can also cache the type of the multi-page closing control aimed at by the triggering operation, and after the current page receives the closing instruction, whether the multi-page closing control aimed at by the triggering operation is all the page controls is judged according to the cached type of the multi-page closing control aimed at by the triggering operation.
In another possible implementation manner, referring to fig. 6, the multi-page control method in the embodiment of the present application includes the following steps:
s601, responding to triggering operation of a multi-page closing control on a current page.
S602, when the multi-page closing control aimed at by the triggering operation is a closing control of all pages, calling the multi-page controller connected with the current page, and sending a closing instruction to all pages connected with the multi-page controller through the multi-page controller so as to close all pages connected with the multi-page controller.
And S603, when the multi-page closing control aimed at by the triggering operation is a closing other page control, calling the multi-page controller connected with the current page, and sending closing instructions to other pages except the current page in all pages connected with the multi-page controller through the multi-page controller so as to close the other pages connected with the multi-page controller.
In practice, after a page is closed, the connection between the page and the multi-page controller is deleted. When all pages connected to a certain multi-page controller are closed, the multi-page controller can be deleted. Of course, the multi-page controller may be maintained for a certain period of time, or deleted after the browser is closed.
Through setting all page controls to be closed and other page controls to be closed, various modes for rapidly closing related pages are provided for a user, so that the user can close all pages belonging to the same website by clicking all page controls to be closed, and can keep a currently browsed page and close other pages related to the current page by clicking other page controls to be closed. When a user opens a plurality of pages of a plurality of websites, all pages or part of pages of a certain website can be quickly closed by closing all page controls or closing other page controls, so that tedious and repeated closing actions one by one are avoided, the cost of repeated operation of the user is reduced, the time is saved, and the user experience is improved.
Referring to fig. 7, on the basis of any of the above embodiments, the connection between any page opened by the user and the multi-page controller may be established as follows:
s701, responding to an operation of opening a page, and acquiring a website identifier to which the page belongs.
In particular implementations, the website is identified as a primary domain name of the website. Wherein the primary domain name is also called top-level domain name, such as baidu.
S702, judging whether a multi-page controller corresponding to the website identification of the page exists, if so, executing step S704, and if not, executing step S703.
S703, creating a corresponding multi-page controller for the website identification of the page, and executing step S704.
S704, establishing connection for the page and the multi-page controller corresponding to the website identification of the page.
And S705, displaying a multi-page closing control corresponding to the multi-page controller on the page.
In specific implementation, the corresponding multi-page controller can be created for the website identifier of the webpage opened by the user by any one of the following modes:
in the first way, a sharedWorker (sharing thread) is created in the browser and used as a multi-page controller corresponding to the website identifier of the current page.
The SharedWorker is a technology implemented in a browser and used for communicating among a plurality of pages, and a shared thread can be created by the SharedWorker, namely, a unique thread is created in the life cycle of a page connected with the shared thread by using the same SharedWorker, sharedWorker by using different pages, and the thread is also ended when all the pages connected with the SharedWorker are closed by using the same thread together by a plurality of pages connected with the SharedWorker.
For this purpose, a shared thread SharedWorker for multiple pages can be created at the browser end, and the shared SharedWorker is used as a multiple page controller. And when the ShareWorker monitors a trigger event of the multi-page closing control in any page connected with the ShareWorker, triggering the ShareWorker to broadcast a closing instruction to all pages connected with the ShareWorker.
In the second mode, a localtorage is created in the browser, and is used as a multi-page controller corresponding to the website identifier of the current page, and a closing instruction state is stored in the localtorage.
Accordingly, a connection may be established for the current page and its corresponding multi-page controller by: and adding a monitoring onstore event and a storage event on a window object of the current page.
The Web Storage API has a set of event notification mechanisms built therein, and when the content of the Storage space Localstorage changes (including adding, modifying, deleting data), the Storage event or onstore event is automatically triggered and sent to all interested listeners.
Therefore, in implementation, a multi-page shared storage space Localstorage can be created at the browser end, and then a multi-page controller corresponding to the website identifier of the current page is used, and a monitoring onstore event and a storage event, namely a monitoring onstore event and a storage event of each page connected with the storage space Localstorage, are directly added on the window object, so that communication among a plurality of pages is realized. The Localstorage is used as a multi-page controller and used for storing a closing instruction state, the initial closing instruction state is not closed, after a multi-page closing control in any page connected with the Localstorage is triggered, the Localstorage responds to the triggering operation to modify the closing instruction state into closing, a storage event with the modified closing instruction state is generated, and each page connected with the Localstorage can monitor the storage event, so that a closing instruction is obtained.
And in a third mode, sending a creation request to the background server so that the background server creates the website identifier of the current page to create a corresponding multi-page controller.
The first two ways are to create a multi-page controller in the browser, and the third way is to create a multi-page controller in the background server.
Accordingly, a connection may be established for the current page and its corresponding multi-page controller by: and establishing a WebSocket connection for the current page and the multi-page controller in the background server, or establishing a connection with the multi-page controller in the background server in an ajax polling mode.
The WebSocket mode is a mode of a B/S structure, and all pages are connected with a corresponding multi-page controller in a background server through WebSocket connection. All associated pages may be connected to the same multi-page controller through session (session control). The multi-page controller deployed on the background server performs the same functions and services as the multi-page controller deployed in the browser.
The ajax polling mode is also a mode of a B/S structure, the communication principle is similar to that of WebSocket, namely, the multi-page controller is deployed on a background server, and all pages are connected with the corresponding multi-page controller in the background server through the ajax polling mode.
Exemplary apparatus
Having described the method of the exemplary embodiments of the present application, a description will next be given of the multi-page control apparatus of the exemplary embodiments of the present application.
Fig. 8 is a schematic structural diagram of a multi-page control device 80 according to an embodiment of the present application. In one embodiment, the multi-page control device 80 includes: a response module 801 and a call module 802.
A response module 801, configured to respond to a triggering operation for a multi-page close control on a current page.
And a calling module 802, configured to call the multi-page controller that establishes a connection with the current page, and send a closing instruction to the page that establishes a connection with the multi-page controller through the multi-page controller, so as to close the page that establishes a connection with the multi-page controller, where all the pages that establish a connection with the multi-page controller are associated.
Optionally, the multiple page close control includes closing all page controls and closing other page controls.
The multi-page control device 80 of the embodiment of the present application further includes a closing module 803, configured to close the current page if it is determined that the triggering operation is directed to closing all page controls after the current page receives the closing instruction; if the trigger operation is determined to be aimed at closing other page controls, the current page is not closed.
Optionally, all pages associated with establishing a connection with the multi-page controller belong to the same website.
Optionally, the multi-page control device 80 of the embodiment of the present application further includes: an acquisition module 804, a connection creation module 805, a multi-page controller creation module 806, and a control display module 807.
The obtaining module 804 is configured to obtain, in response to an operation of opening the current page, a website identifier to which the current page belongs.
The connection creation module 805 is configured to, when there is a multi-page controller corresponding to the website identifier to which the current page belongs, establish a connection between the current page and the multi-page controller.
The multi-page controller creation module 806 is configured to create, when there is no multi-page controller corresponding to the website identifier of the current page, a corresponding multi-page controller for the website identifier of the current page.
The connection creation module 805 is further configured to establish a connection for the current page and the multi-page controller corresponding to the website identifier to which the current page belongs.
The control display module 807 is configured to display, on the current page, a multi-page close control corresponding to a multi-page controller of the website identifier to which the current page belongs.
Optionally, the web site to which the web site belongs is identified as a primary domain name of the web site.
Optionally, the multi-page controller creation module 806 is specifically configured to create a SharedWorker in the browser, where the SharedWorker is used as the multi-page controller corresponding to the website identifier of the current page.
Optionally, the multi-page controller creation module 806 is specifically configured to create a localtorage in the browser, where the localtorage is stored with a closing instruction state as a multi-page controller corresponding to the website identifier of the current page.
Accordingly, the connection creation module 805 is specifically configured to establish a connection for the current page and the multi-page controller by adding the listening onstore event and the storage event to the window object of the current page.
Optionally, the multi-page controller creation module 806 is specifically configured to send a creation request to the background server, so that the background server creates the corresponding multi-page controller of the website identifier pair of the current page.
Accordingly, the connection creation module 805 is specifically configured to: and establishing a WebSocket connection for the current page and the multi-page controller in the background server, or establishing a connection with the multi-page controller in the background server in an ajax polling mode.
The multi-page control device provided in the embodiment of the present application and the multi-page control method adopt the same inventive concept, and can achieve the same beneficial effects, and are not described herein again.
Based on the same inventive concept as the multi-page control method, the embodiment of the application also provides an electronic device, which can be a desktop computer, a portable computer, a smart phone, a tablet computer, a personal digital assistant (Personal Digital Assistant, PDA), a server, and the like. As shown in fig. 9, the electronic device 90 may include a processor 901 and a memory 902.
The processor 901 may be a general purpose processor such as a Central Processing Unit (CPU), digital signal processor (Digital Signal Processor, DSP), application specific integrated circuit (Application Specific Integrated Circuit, ASIC), field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, and may implement or perform the methods, steps, and logic blocks disclosed in embodiments of the present application. The general purpose processor may be a microprocessor or any conventional processor or the like. The steps of a method disclosed in connection with the embodiments of the present application may be embodied directly in a hardware processor for execution, or in a combination of hardware and software modules in the processor for execution.
The memory 902 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. The Memory may include at least one type of storage medium, which may include, for example, flash Memory, hard disk, multimedia card, card Memory, random access Memory (Random Access Memory, RAM), static random access Memory (Static Random Access Memory, SRAM), programmable Read-Only Memory (Programmable Read Only Memory, PROM), read-Only Memory (ROM), charged erasable programmable Read-Only Memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), magnetic Memory, magnetic disk, optical disk, and the like. The memory is any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited to such. The memory 902 of the present embodiment may also be circuitry or any other device capable of implementing a memory function for storing program instructions and/or data.
Exemplary program product
The embodiment of the application provides a computer readable storage medium for storing computer program instructions for the electronic device, which contains a program for executing the multi-page control method.
The computer storage media described above can be any available media or data storage device that can be accessed by a computer, including, but not limited to, magnetic storage (e.g., floppy disks, hard disks, magnetic tape, magneto-optical disks (MOs), etc.), optical storage (e.g., CD, DVD, BD, HVD, etc.), and semiconductor storage (e.g., ROM, EPROM, EEPROM, nonvolatile storage (NAND FLASH), solid State Disk (SSD)), etc.
In some possible implementations, the various aspects of the present application may also be implemented as a computer program product comprising program code for causing a server device to perform the steps of the multi-page control method according to the various exemplary embodiments of the present application as described in the section "exemplary method" above in this specification, when the computer program product is run on the server device.
The computer program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium would include the following: an electrical connection having one or more wires, a portable disk, a hard disk, random Access Memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
A computer program product for multi-page control according to embodiments of the present application may employ a portable compact disc read-only memory (CD-ROM) and include program code and may run on a server device. However, the program product of the present application is not limited thereto, and in this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
The readable signal medium may include a data signal propagated in baseband or as part of a carrier wave with readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A readable signal medium may also be any readable medium that is not a readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Program code for carrying out operations of the present application may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computing device, partly on a remote computing device, or entirely on the remote computing device or server. In the case of remote computing devices, the remote computing device may be connected to the user computing device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computing device (e.g., connected via the Internet using an Internet service provider).
It should be noted that although several units or sub-units of the apparatus are mentioned in the above detailed description, such a division is merely exemplary and not mandatory. Indeed, the features and functions of two or more of the elements described above may be embodied in one element in accordance with embodiments of the present application. Conversely, the features and functions of one unit described above may be further divided into a plurality of units to be embodied.
Furthermore, although the operations of the methods of the present application are depicted in the drawings in a particular order, this is not required to or suggested that these operations must be performed in this particular order or that all of the illustrated operations must be performed in order to achieve desirable results. Additionally or alternatively, certain steps may be omitted, multiple steps combined into one step to perform, and/or one step decomposed into multiple steps to perform.
While the spirit and principles of this application have been described with reference to several particular embodiments, it is to be understood that this application is not limited to the disclosed particular embodiments nor does it imply that features in the various aspects are not useful in combination, nor are they intended to be in any way useful for the convenience of the description. The application is intended to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims.