Disclosure of Invention
In view of the foregoing, it is desirable to provide a method, a system, a device and a storage medium for controlling browser rollback.
A browser backspacing control method comprises the following steps: initializing a browser backspacing control object, registering a browser backspacing function, and binding the browser backspacing function with a callback trigger function; registering and storing a browser backspacing control function according to the browser backspacing function; judging whether a historical backspacing control function exists in a function queue, if so, removing the historical backspacing control function in the function queue, and adding the browser backspacing control function into the function queue; and triggering the callback trigger function, and controlling the browser to retreat according to the browser retreat control function in the function queue.
In one embodiment, the initializing a browser fallback control object, registering a browser fallback function, and binding with a callback trigger function specifically includes: clearing the functions stored in the function queue and registering a browser backspacing function; monitoring the change of a browser history recording interface through a browser object; and binding the browser backspacing function with a callback trigger function.
In one embodiment, the registering and storing a browser fallback control function according to the browser fallback function specifically includes: registering a browser backspacing control function according to the browser backspacing function, and transmitting the browser backspacing control function into a browser; judging whether an incoming browser backspacing control function is registered, if not, storing the browser backspacing control function to a function queue; judging whether the browser backspacing control function controls the backspacing of the browser, if not, pushing an anchor address according to the browser backspacing control function, and controlling the backspacing of the browser through the anchor address.
In one embodiment, the determining whether a historical rollback control function exists in the function queue, and if so, removing the historical rollback control function from the function queue, and adding the browser rollback control function to the function queue specifically includes: transmitting the browser backspacing control function into a browser, and judging whether a historical backspacing control function exists in a function queue; if the function queue has a historical rollback control function, removing the historical rollback control function; judging whether the historical backspacing control function is removed when the function queue is in the function queue, and controlling the backspacing of a browser; and if so, backing off and refreshing, and removing the browser backspacing control function.
In one embodiment, the removing the browser rollback control function specifically includes: finding out subscripts of functions to be removed from the function queues, and judging whether the subscripts are greater than or equal to 0; if the subscript is greater than or equal to 0, the function to be removed exists in the function queue; removing the corresponding function to be removed in the function queue according to the subscript; and removing the anchor point address corresponding to the function to be removed.
In one embodiment, the triggering the callback trigger function, and controlling browser rollback according to a browser rollback control function in a function queue specifically includes: triggering the callback trigger function, and judging whether the function queue is empty or not; if the function queue is not empty, traversing a browser backspacing control function in the function queue, executing the browser backspacing control function, pushing an anchor address, and controlling the browser to backspace according to the anchor address; if the function queue is empty and it is detected that the browser has rolled back, then the anchor address is removed.
In one embodiment, the triggering the callback trigger function, and controlling browser rollback according to a browser rollback control function in a function queue, further includes: detecting whether a user is a manager or not, and returning to the previous page and refreshing when the user is the manager; detecting whether the current interface is a preset interface or not, whether the current time is within a preset time period or not, and returning to the previous page and refreshing when the current interface is a non-preset interface or the current time is not within the preset time period; and returning to the previous page and refreshing when detecting that the user continuously clicks the browser backspace control for at least 3 seconds.
A browser rollback control system, comprising: the backspacing function registration module is used for initializing a backspacing control object of the browser, registering a backspacing function of the browser and binding the backspacing function with the backspacing trigger function; a rollback control function registration module, configured to register and store a browser rollback control function according to the browser rollback function; a rollback control function adding module, configured to determine whether a historical rollback control function exists in a function queue, and if the historical rollback control function exists, remove the historical rollback control function in the function queue and add the browser rollback control function to the function queue; and the browser backspacing control module is used for triggering the callback trigger function and controlling the backspacing of the browser according to the browser backspacing control function in the function queue.
An apparatus comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the steps of a browser rollback control method as described in the above embodiments when executing the program.
A storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of a browser rollback control method as described in the various embodiments above.
Compared with the prior art, the invention has the advantages and beneficial effects that: the invention provides a browser backspacing control method meeting the use habits of all users, so that the user can not directly quit the applet and the app no matter which quit mode is used, the conventional operation habits of the user are met, backspacing of the browser for retaining temporary data, page positions and returned data can be realized, and the use experience of the user is improved.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings by way of specific embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The method and the device are suitable for backspacing control of the browser, and the situation that the previous page data is refreshed due to the adoption of a traditional browser backspacing mode is avoided. According to the method and the device, a browser backspacing control object is initialized, functions stored in a function queue are cleared, a browser backspacing function is registered and bound with a callback trigger function, the change of a browser historical record interface is monitored through the browser object, whether the browser has operations of backspacing, returning or the last page is judged, and therefore backspacing of the browser is controlled in time.
Registering a browser backspacing control function according to a browser backspacing function, transmitting the browser backspacing control function into a browser, judging whether the browser backspacing control function is registered or not, if not, storing the browser backspacing control function into a function queue, judging whether the browser backspacing control function controls the browser to backspace or not, if not, pushing an anchor address according to the browser backspacing function, and skipping to the corresponding anchor address by the browser to realize the backspace of the previous page data.
Judging whether a historical backspacing function exists in the function queue, if so, removing the function queue to avoid the interference of the historical backspacing control function on the backspacing operation of the current browser; if the browser is removed and the browser is successfully backed, backing and refreshing are carried out, and the browser backing control function is removed; when a callback trigger function is triggered, judging whether a function queue is empty or not, if the function queue is not empty, traversing a browser rollback control function in the function queue, executing the browser rollback control function, pushing an anchor point address, namely a pre-stored previous page reserved with corresponding page data, skipping to the anchor point address by the browser, realizing the rollback of the previous page data reserved by the browser, meeting the conventional operation habit of a user, and if the function queue is empty and the browser rolls back, backing and refreshing, removing the anchor point address, thereby reducing the memory occupation of the browser.
In addition, when detecting that the user is a manager, or the current interface is a non-preset interface, or the current time is not in a preset time period, or detecting that the user continuously clicks a browser backspacing control for at least three seconds, the previous page is returned and refreshed in a conventional backspacing mode, so that the random switching between conventional backspacing and the backspacing of the application is realized, and the user requirements are met. The method and the device for closing the popup window meet the conventional operation habit of the user, the browser is enabled to keep the temporary data, the page position and the returned data, the user use experience is improved, meanwhile, the popup window can be closed through the returning operation of the browser, and the user is prevented from exiting the caused misoperation in a conventional mode.
In one embodiment, as shown in fig. 1, there is provided a browser rollback control method, including the steps of:
step S101, initializing a browser backspacing control object, registering a browser backspacing function, and binding with a callback trigger function.
Specifically, in order to ensure that the browser can store the temporary filling data, the page position and the return data of the previous page when the browser backs, before the browser backs, a browser backspacing control object is initialized, a browser backspacing function is re-registered, repeated registration of a callback is prevented, and the browser backspacing function and a callback trigger function are bound, so that the browser backspacing function can be started by triggering the callback trigger function.
And step S102, registering and storing the browser backspace control function according to the browser backspace function.
Specifically, according to the browser backspacing function, the browser backspacing control function is re-registered, whether the browser backspacing control function is registered or not is judged, if the browser backspacing control function is not registered, the browser backspacing control function is stored in the function queue, backspacing of the browser is controlled through the browser backspacing control function, and meanwhile, the fact that the browser can return to a previously filled position after backspacing, and temporarily filled data and returned data are stored can be guaranteed.
Step S103, judging whether a historical backspacing control function exists in the function queue, if so, removing the historical backspacing control function in the function queue, and adding the browser backspacing control function into the function queue.
Specifically, in order to avoid the situation that the current page rollback control is interfered due to the existence of the historical rollback control function in the function queue, it is necessary to determine whether the historical rollback control function exists in the function queue, and if the historical rollback control function exists in the function queue, the historical rollback function is removed from the function queue, and the registered browser rollback control function is added to the function queue, so that the rollback of the browser can be controlled according to the browser rollback control function.
And step S104, triggering a callback trigger function, and controlling the browser to retreat according to the browser retreat control function in the function queue.
Specifically, when a browser rollback request is initiated and a callback trigger function is triggered, the browser is controlled to return to the previous page under the condition that the filling position of the previous page, the temporary filling data and the return data are saved according to the browser rollback control function stored in the function queue, and the rollback of the browser is achieved.
In the embodiment, a browser rollback control object is initialized, a browser rollback function is registered and bound with a callback trigger function, a browser rollback control function is registered and stored according to the browser rollback function, whether a historical rollback function exists in a function queue is judged, if the historical rollback function exists in the function queue is removed, the browser rollback control function is added into the function queue, the callback trigger function is triggered, and the browser rollback is controlled according to the browser rollback control function in the function queue, so that the browser can keep temporary data, page positions and rollback of returned data through conventional habit operation of a user, meanwhile, closing of a popup window can be realized through return operation of the browser, error operation caused by the user through a conventional exit mode is avoided, and user experience is improved.
Wherein, step S101 specifically includes: clearing the functions stored in the function queue and registering a browser backspacing function; monitoring the change of a browser history recording interface through a browser object; and binding the browser backspacing function with the callback trigger function.
Specifically, before controlling browser rollback, emptying functions stored in a function queue, re-registering browser rollback functions, monitoring changes of a history interface popstate through a browser object window, if changes of the history interface popstate are monitored, indicating that the browser has a return operation, a rollback operation or a previous page operation, triggering the callback trigger function when the operations exist, and executing the browser rollback functions after the callback trigger function is triggered due to the fact that the browser rollback functions are bound with the callback trigger functions.
Wherein, step S102 specifically includes: registering a browser backspacing control function according to the browser backspacing function, transmitting the browser backspacing control function into a browser, judging whether the transmitted browser backspacing control function is registered, and if the transmitted browser backspacing control function is not registered, storing the browser backspacing control function into a function queue; judging whether the browser backspacing control function controls the backspacing of the browser, if not, pushing an anchor address according to the browser backspacing control function, and controlling the backspacing of the browser through the anchor address.
Specifically, a browser backspacing control function is registered according to the browser backspacing function, the browser backspacing control function is transmitted to the browser, whether the transmitted browser is registered or not is judged, and if the transmitted browser is registered, the current operation is ended; if not, saving the browser rollback control function in the function queue, judging whether the browser rollback control function controls the browser to rollback or not, and if so, ending the operation; if the browser is not controlled to back, pushing an anchor address through a browser back control function, and controlling the browser to back through the anchor address. When the page is operated, the current page is marked with an anchor point, and an anchor point address is obtained; and after the backspacing trigger function is triggered, executing a browser backspacing control function, pushing an anchor address through the browser backspacing control function, skipping to the anchor address, realizing browser backspacing, and saving the previously retained data and page position.
When judging whether the browser rollback control function controls the browser to rollback or not, the anchor address of the current page can be read through the window.
Wherein, step S103 specifically includes: transmitting a browser backspacing control function into a browser, and judging whether a historical backspacing control function exists in a function queue; if the historical backspacing control function exists in the function queue, removing the historical backspacing control function; judging whether the historical backspacing control function is removed from the function queue and controlling the backspacing of the browser; if yes, backing off and refreshing, and removing the browser backspacing control function.
Specifically, after a browser backspacing control function is transmitted into a browser, whether a historical backspacing function exists in a function queue is judged, in order to avoid interference of the historical backspacing function on a current backspacing operation, when the historical backspacing control function exists in the function queue, the corresponding historical backspacing control function needs to be removed, and therefore backspacing of the browser can be controlled through the transmitted browser backspacing control function. After the historical backspacing control function is removed, whether the function queue removes the historical backspacing control function or not is detected, whether the browser backspacing is controlled or not is detected, if the function queue removes the historical backspacing control function and controls the browser to backspace, a page is backed by a method of window.
The method for removing the browser backspacing control function specifically comprises the following steps: finding out subscripts of functions to be removed from the function queues, and judging whether the subscripts are greater than or equal to 0; if the subscript is greater than or equal to 0, the function to be removed exists in the function queue; removing the corresponding function to be removed in the function queue according to the subscript; and removing the anchor point address corresponding to the function to be removed.
Specifically, when a browser rollback control function is moved, a subscript of a function to be removed needs to be found out from a function queue, the function to be removed is the browser rollback control function which controls the browser to realize rollback, whether the subscript is greater than or equal to 0 is judged, when the subscript is greater than or equal to 0, the function to be removed exists in the function queue, the corresponding function to be removed is removed from the function queue through the subscript, an anchor address corresponding to the function to be removed is removed, interference on next browser rollback is avoided, browser storage can be cleaned at the same time, and jamming caused by too much storage occupation of the browser is avoided.
Wherein, step S104 specifically includes: triggering and calling back a trigger function, and judging whether a function queue is empty or not; if the function queue is not empty, traversing the browser rollback control function in the function queue, executing the browser rollback control function, pushing an anchor address, and controlling the browser to rollback according to the anchor address; if the function queue is empty and it is detected that the browser has rolled back, then the anchor address is removed.
Specifically, when browser rollback is needed, a conventional browser returning operation is performed, a callback trigger function is triggered, whether a current function queue is empty or not is judged, when the function queue is not empty, browser rollback control functions in the function queue are traversed, the browser rollback control functions are sequentially executed, an anchor address is pushed again, and the browser skips according to the anchor address to realize browser rollback; after the function queue is empty and it is detected that the browser has been controlled to implement a fallback, it is backed and refreshed by the method of window.
Specifically, after the callback function is triggered, if the function queue is detected to be empty and the browser is backed, the browser is indicated to be backed by the browser back control function, and the browser is backed by one page through window.
Wherein, step S104 further includes: detecting whether a user is a manager or not, and returning to the previous page and refreshing when the user is the manager; detecting whether the current interface is a preset interface or not, whether the current time is within a preset time period or not, and returning to the previous page and refreshing when the current interface is a non-preset interface or the current time is not within the preset time period; and returning to the previous page and refreshing when detecting that the user continuously clicks the browser backspace control for at least 3 seconds.
Specifically, after the callback function is triggered, whether the current user is a manager or not is detected through the mark of the terminal user, and when the user is the manager, the browser backspacing control method is not adopted, but the conventional browser backspacing control is adopted, namely the previous page is returned and refreshed. When browser backspacing control is carried out, the browser backspacing control method can be set on a page needing form filling, and a conventional backspacing method is adopted on a conventional page, so that when the current page is detected to be a non-preset interface, the previous page is directly returned and refreshed, and similarly, when the current time is detected to be in a non-preset time period, the conventional backspacing method is also adopted. In addition, when the situation that the user continuously clicks the browser backspacing control for at least three seconds is detected, the previous page is returned and refreshed by adopting a conventional backspacing method, so that the random switching between the backspacing method and the conventional backspacing method is realized, and the requirements of the user are met.
In this embodiment, the monitoring of the browser rollback request is realized through the pop state of the HTML5, and meanwhile, the rollback control of the browser for reserving the original data is realized through the HTML anchor point. Firstly, the page does not trigger refreshing in an anchor point jumping mode, so that the previous data is processed; secondly, through anchor jumping, anchor connection can occupy a url history, and through browser rollback, anchor connection can be rolled back. The browser rollback control is set, the rollback of the browser is controlled by pushing an anchor connection, the browser is rolled back to the browser quality of the browser from the anchor connection, the roll-back of the browser is triggered to roll back and monitor, in a monitoring function, an anchor connection is pushed again, so that circulation is formed, and the browser cannot roll back to the previous page under the condition that the roll-back control is not closed.
As shown in fig. 2, there is provided a browser rollback control system 20, including: a fallback function registration module 21, a fallback control function registration module 22, a fallback control function adding module 23 and a browser fallback control module 24, wherein:
a rollback function registration module 21, configured to initialize a browser rollback control object, register a browser rollback function, and bind the rollback function with a callback trigger function;
a rollback control function registration module 22, configured to register and store a browser rollback control function according to the browser rollback function;
a rollback control function adding module 23, configured to determine whether a historical rollback control function exists in the function queue, and if the historical rollback control function exists, remove the historical rollback control function in the function queue, and add the browser rollback control function to the function queue;
and the browser rollback control module 24 is used for triggering and calling back the trigger function and controlling the rollback of the browser according to the browser rollback control function in the function queue.
In an embodiment, the fallback function registration module 21 is specifically configured to: clearing the functions stored in the function queue and registering a browser backspacing function; monitoring the change of a browser history record interface popstate through a browser object window; and binding the browser backspacing function with the callback trigger function.
In one embodiment, the fallback control function registration module 22 is specifically configured to: registering a browser backspacing control function according to the browser backspacing function, transmitting the browser backspacing control function into a browser, judging whether the transmitted browser backspacing control function is registered, and if the transmitted browser backspacing control function is not registered, storing the browser backspacing control function into a function queue; judging whether the browser backspacing control function controls the backspacing of the browser, if not, pushing an anchor address according to the browser backspacing control function, and controlling the backspacing of the browser through the anchor address.
In one embodiment, the rollback control function adding module 23 is specifically configured to: transmitting a browser backspacing control function into a browser, and judging whether a historical backspacing control function exists in a function queue; if the historical backspacing control function exists in the function queue, removing the historical backspacing control function; judging whether the historical backspacing control function is removed from the function queue and controlling the backspacing of the browser; if yes, backing and refreshing by the method of window.
In one embodiment, the browser rollback control module 24 is specifically configured to: triggering and calling back a trigger function, and judging whether a function queue is empty or not; if the function queue is not empty, traversing the browser rollback control function in the function queue, executing the browser rollback control function, pushing an anchor address, and controlling the browser to rollback according to the anchor address; if the function queue is empty, the anchor address is removed.
In this embodiment, a rollback control object of a browser is initialized by a rollback function registration module 21, a browser rollback function is re-registered and bound to a callback trigger function, a browser rollback control function is registered by a rollback control function registration module 22 and stored in a function queue, whether a historical rollback control function exists in the function queue is determined by a rollback control function adding module 23, when the historical rollback control function exists, the historical rollback control function is removed, the browser rollback control function is added to the function queue, when the callback trigger function is triggered, the browser is controlled to roll back according to the browser rollback control function in the function queue by a browser rollback control module 24, so that a popup window can be closed by a browser roll-back mode in a popup window page, for example, a physical rollback key or a rollback gesture of an android device, the data of the previous page of the browser is kept, meanwhile, the conventional operation habits of the user are met, and the use experience of the user is improved.
In one embodiment, a device is provided, which may be a server, and its internal structure diagram may be as shown in fig. 3. The device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the processor of the device is configured to provide computing and control capabilities. The memory of the device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The database of the device is used for storing configuration templates and also can be used for storing target webpage data. The network interface of the device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a browser rollback control method.
Those skilled in the art will appreciate that the configuration shown in fig. 3 is a block diagram of only a portion of the configuration associated with the present application and does not constitute a limitation on the devices to which the present application may be applied, and that a particular device may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a storage medium may also be provided, the storage medium storing a computer program comprising program instructions which, when executed by a computer, may be part of a browser rollback control system as mentioned above, cause the computer to perform the method according to the previous embodiment.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), or the like.
It will be apparent to those skilled in the art that the modules or steps of the invention described above may be implemented in a general purpose computing device, they may be centralized on a single computing device or distributed across a network of computing devices, and optionally they may be implemented in program code executable by a computing device, such that they may be stored on a computer storage medium (ROM/RAM, magnetic disks, optical disks) and executed by a computing device, and in some cases, the steps shown or described may be performed in an order different than that described herein, or they may be separately fabricated into individual integrated circuit modules, or multiple ones of them may be fabricated into a single integrated circuit module. Thus, the present invention is not limited to any specific combination of hardware and software.
The foregoing is a more detailed description of the present invention that is presented in conjunction with specific embodiments, and the practice of the invention is not to be considered limited to those descriptions. For those skilled in the art to which the invention pertains, several simple deductions or substitutions can be made without departing from the spirit of the invention, and all shall be considered as belonging to the protection scope of the invention.