Disclosure of Invention
The embodiment of the invention provides a method and a device for realizing a historical record function of a webpage, which can improve user experience.
In a first aspect, an embodiment of the present invention provides a method for implementing a web page history recording function, including:
acquiring a current Uniform Resource Locator (URL) of a current webpage;
storing the acquired current URL into a preset historical record array; wherein the history array is set in a data cookie stored on the user's local terminal;
further comprising:
acquiring a target URL from the historical record array of the cookie;
and displaying a target webpage corresponding to the target URL according to the target URL.
Preferably, the first and second electrodes are formed of a metal,
before the storing the obtained current URL into a preset history array, the method further includes:
at least one historical URL is pre-stored in the historical record array, and the at least one historical URL is sequenced according to the storage time corresponding to each historical URL;
the storing the acquired current URL into a preset historical record array comprises:
determining the last history URL in the sequence according to the sequencing result of the at least one history URL;
determining whether the current URL is the same as the last historical URL, if not, storing the current URL in the historical record array;
preferably, the first and second electrodes are formed of a metal,
the storing the acquired current URL into a preset historical record array comprises:
determining a home page identifier of a network home page corresponding to the current webpage;
determining whether the home page identifier exists in the current URL, if so, removing the home page identifier, and storing the removed current URL into the historical record array;
preferably, the first and second electrodes are formed of a metal,
when the number of the history arrays set in the cookie is at least two, before storing the acquired current URL in a preset history array, the method further includes:
determining an array identifier corresponding to each historical record array;
then the process of the first step is carried out,
the storing the acquired current URL into a preset historical record array comprises:
analyzing the current URL and determining a characteristic identifier corresponding to the current URL;
determining a historical record array corresponding to the current URL according to the feature identifier and array identifiers respectively corresponding to the historical record arrays;
and storing the current URL into the determined historical record array.
Preferably, the first and second electrodes are formed of a metal,
the obtaining a target URL from the history array of cookies includes:
determining a target history array from at least two of the histories;
and determining the URL with the shortest storage time in the target historical record array according to the storage time sequence of each URL in the target historical record array, and taking the determined URL as the target URL.
Preferably, the first and second electrodes are formed of a metal,
after the storing the obtained current URL into a preset history array, further comprising:
determining the number of URLs in the history array;
updating the number of the preset historical records in the cookie according to the determined number of the URLs;
then the process of the first step is carried out,
the obtaining a target URL from the history array of cookies includes:
and determining whether the number of the historical records is larger than a preset threshold value, and if so, acquiring a target URL from the historical record array of the cookie.
Preferably, the first and second electrodes are formed of a metal,
after the displaying the target webpage corresponding to the target URL according to the target URL, further comprising:
deleting the target URL from the history array and updating the history number in the cookie.
In a second aspect, an embodiment of the present invention provides an apparatus for implementing a web page history recording function, including: the system comprises a URL acquisition unit, a URL storage unit and a webpage display unit; wherein,
the URL obtaining unit is used for obtaining a current uniform resource locator URL of a current webpage;
the URL storage unit is used for storing the acquired current URL into a preset historical record array; wherein the history array is set in a data cookie stored on the user's local terminal;
and the webpage display unit is used for acquiring a target URL from the historical record array of the cookie and displaying a target webpage corresponding to the target URL according to the target URL.
Preferably, the first and second electrodes are formed of a metal,
the URL storage unit is used for pre-storing at least one historical URL in the historical record array and sequencing the at least one historical URL according to the storage time corresponding to each historical URL; determining the last history URL in the sequence according to the sequencing result of the at least one history URL; determining whether the current URL is the same as the last historical URL, if not, storing the current URL in the historical record array;
preferably, the first and second electrodes are formed of a metal,
the URL storage unit is used for determining a home page identifier of a network home page corresponding to the current webpage, determining whether the home page identifier exists in the current URL, if so, clearing the home page identifier, and storing the cleared current URL into the historical record array;
preferably, the first and second electrodes are formed of a metal,
when the number of the historical record arrays set in the cookie is at least two, the URL storage unit is used for determining an array identifier corresponding to each historical record array, analyzing the current URL and determining a feature identifier corresponding to the current URL; determining a historical record array corresponding to the current URL according to the feature identifier and array identifiers respectively corresponding to the historical record arrays; storing the current URL into the determined historical record array;
the webpage display unit is used for determining a target historical record array from at least two historical records; and determining the URL with the shortest storage time in the target historical record array according to the storage time sequence of each URL in the target historical record array, and taking the determined URL as the target URL.
Preferably, the first and second electrodes are formed of a metal,
further comprising: an update unit; wherein,
the updating unit is used for determining the number of the URLs in the historical record array after the URL storage unit stores the acquired current URL into a preset historical record array, and updating the preset historical record number in the cookie according to the determined number of the URLs;
and the webpage display unit is used for determining whether the number of the historical records is greater than a preset threshold value, and if so, acquiring a target URL from the historical record array of the cookie.
The embodiment of the invention provides a method and a device for realizing a webpage history recording function, wherein after a current Uniform Resource Locator (URL) of a current webpage is obtained, the current URL is stored in a history recording array of a cookie. When the historical record webpage needs to be accessed, the target URL can be obtained from the historical record array of the cookie, and the corresponding target webpage, namely the historical record webpage, is displayed according to the target URL, so that the historical record function of the webpage is realized, and a user can directly jump to other historical record webpages from the currently accessed webpage, so that the user experience is improved.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer and more complete, the technical solutions in the embodiments of the present invention will be described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention, and based on the embodiments of the present invention, all other embodiments obtained by a person of ordinary skill in the art without creative efforts belong to the scope of the present invention.
As shown in fig. 1, an embodiment of the present invention provides a method for implementing a web page history recording function, where the method may include the following steps:
step 101: acquiring a current Uniform Resource Locator (URL) of a current webpage;
step 102: storing the acquired current URL into a preset historical record array; wherein the history array is set in a data cookie stored on the user's local terminal;
step 103: acquiring a target URL from the historical record array of the cookie;
step 104: and displaying a target webpage corresponding to the target URL according to the target URL.
In the above embodiment, after the current URL of the current web page is acquired, the current URL is stored in the history array of the cookie. When the historical record webpage needs to be accessed, the target URL can be obtained from the historical record array of the cookie, and the corresponding target webpage, namely the historical record webpage, is displayed according to the target URL, so that the historical record function of the webpage is realized, and a user can directly jump to other historical record webpages from the currently accessed webpage, so that the user experience is improved.
In an embodiment of the present invention, before step 102, further comprising:
at least one historical URL is pre-stored in the historical record array, and the at least one historical URL is sequenced according to the storage time corresponding to each historical URL;
specific embodiments of step 102 may include:
determining the last history URL in the sequence according to the sequencing result of the at least one history URL;
determining whether the current URL is the same as the last history URL, and if not, storing the current URL in the history array.
In this embodiment, history URLs are pre-stored in the history array, and the history URLs are arranged according to the storage time sequence, for example, A, B and C are pre-stored in the history array, a is stored in the history array first, C is stored in the history array last, and the arrangement sequence of A, B and C is a-B-C. After the current URL corresponding to the current webpage is obtained, whether the current URL is the same as the historical URL C or not is judged, if yes, the current webpage is returned through a returning operation, and therefore the corresponding historical record is not added, if not, the current webpage is a reopened webpage, the current URL is stored in the historical record array, the current webpage can be conveniently returned through other webpages subsequently, and the webpage historical record function is achieved. Therefore, only the current URL different from the last historical URL is stored in the historical record array, the same URL is prevented from being repeatedly stored, the same webpage is prevented from being returned for many times, the selection of the target URL is facilitated, and the user experience is further improved.
In an embodiment of the present invention, the detailed implementation of step 102 may include:
determining a home page identifier of a network home page corresponding to the current webpage;
and determining whether the home page identifier exists in the current URL, if so, clearing the home page identifier, and storing the cleared current URL into the historical record array.
The home page identification is a plurality of specific parameters existing in the URL, if the home page identification exists in the URL, the system performs specific operations according to the parameters after the webpage corresponding to the URL is opened, for example, some browsers of android programs check some links in the webpage corresponding to the URL having the home page identification after the webpage corresponding to the URL is opened, and when the home page is returned again, the check is not required again because the check is performed before. In order to avoid redundant operation when the webpage is returned, when the current URL is stored, the home page identifier in the current URL is removed, for example, the home page identifier is removed through global variable processing, and then the current URL after the home page identifier is removed is stored, so that the work flow of returning the historical webpage is reduced, and the realization efficiency of the historical webpage recording function is improved.
In an embodiment of the present invention, when the number of the history arrays set in the cookie is at least two, before step 102, the method may further include:
determining an array identifier corresponding to each historical record array;
specific embodiments of step 102 may include:
analyzing the current URL and determining a characteristic identifier corresponding to the current URL;
determining a historical record array corresponding to the current URL according to the feature identifier and array identifiers respectively corresponding to the historical record arrays;
and storing the current URL into the determined historical record array.
In this embodiment, when the number of the history arrays in the cookie is at least two, for example, there are two history arrays a and b in the cookie, which correspond to hundredths and google respectively, the array identifier of the array a is baidu, the array identifier of the array b is google, and after the current URL is obtained, according to the feature identifier in the current URL, taking baidu as an example, it is determined that the history array corresponding to the current URL is a, so that the current URL is stored in the history array a.
Based on this, in an embodiment of the present invention, the detailed implementation of step 103 may include:
determining a target history array from at least two of the histories;
and determining the URL with the shortest storage time in the target historical record array according to the storage time sequence of each URL in the target historical record array, and taking the determined URL as the target URL.
When the history function needs to be utilized, a target history array is determined from the history arrays A and B, for example, the determined history array is array A, namely an array corresponding to hundred degrees. And selecting the URL with the shortest storage time according to the storage time sequence of each URL in the array. For example, three URLs A, B and C are stored in the array a, a is stored in the array a first, and C is stored in the array a last, that is, the storage time length of a is longest, and the storage time length of C is shortest, then C is taken as the target URL. Therefore, the corresponding target URL is selected from the target historical record array, so that when the webpage historical record function is realized, jumping can be performed among webpages corresponding to all URLs included in the array with the same array identification, namely, visited historical webpages all have the same characteristic identification, a user can conveniently visit the webpages with the same characteristic, and the user experience is further improved.
In an embodiment of the present invention, after step 102, the method further includes:
determining the number of URLs in the history array;
updating the number of the preset historical records in the cookie according to the determined number of the URLs;
specific embodiments of step 103 may include:
and determining whether the number of the historical records is larger than a preset threshold value, and if so, acquiring a target URL from the historical record array of the cookie.
After the current URL is stored, the number of URLs in the history array is determined, for example, if the number of URLs in the history data before storage is 5, after the current URL is stored, the number is increased from 5 to 6, and a variable for storing the number of the history in the cookie is updated according to the stored number. When the target URL is determined from the history array, it is first determined whether the number of history records in the cookie is greater than a preset threshold, for example, when the preset threshold is 1, if the number of history records is less than 1, it is determined that the target URL enters the browser for the first time, and at this time, default processing operations are performed, for example, a corresponding top page or other pre-specified pages are opened. And if the number of the history records is more than 1, taking the last URL in the history record array as the target URL. Therefore, the number of the historical records is updated in time, corresponding number prompt is conveniently carried out on the user when the user accesses the historical records, and user experience is further improved.
In an embodiment of the present invention, after step 104, the method may further include:
deleting the target URL from the history array and updating the history number in the cookie.
And after the webpage corresponding to the target URL is displayed, deleting the target URL in the historical record array, and updating the historical record number in the cookie, so that after the user visits the corresponding historical webpage, the corresponding URL is deleted in time, the URLs in the historical record array are managed conveniently, and the user experience is further improved.
As shown in fig. 2, an embodiment of the present invention provides a method for implementing a web page history recording function, where the method may include the following steps:
step 201: and acquiring the current URL of the current webpage.
Step 202: and judging whether the current URL is the same as the last historical URL in the historical record array preset in the cookie, if so, ending the current flow, otherwise, executing the step 203.
For example, history URLs are pre-stored in the history array, and the history URLs are arranged according to the storage time sequence, for example, A, B and C are pre-stored in the history array, a is stored in the history array first, C is stored in the history array last, and the arrangement sequence of A, B and C is a-B-C. After the current URL corresponding to the current webpage is obtained, whether the current URL is the same as the historical URL C is judged, if yes, the current webpage is returned through a return operation, and therefore the corresponding historical record is not added.
Step 203: and judging whether the home page identifier exists in the current URL, if so, executing the step 204, otherwise, executing the step 205.
Step 204: the home page identification is cleared and step 205 is performed.
The home page identification is a plurality of specific parameters existing in the URL, if the home page identification exists in the URL, the system performs specific operations according to the parameters after the webpage corresponding to the URL is opened, for example, some browsers of android programs check some links in the webpage corresponding to the URL having the home page identification after the webpage corresponding to the URL is opened, and when the home page is returned again, the check is not required again because the check is performed before. In order to avoid redundant operations when returning to the web page, when storing the current URL, the home page identifier in the current URL is cleared, for example, by global variable processing.
Step 205: and storing the current URL into a history record array, determining the number of URLs in the history record array, and updating the preset history record number in the cookie according to the determined number of URLs.
After the current URL is stored, the number of URLs in the history array is determined, for example, if the number of URLs in the history data before storage is 5, after the current URL is stored, the number is increased from 5 to 6, and a variable for storing the number of the history in the cookie is updated according to the stored number.
Step 206: and reading the number of the historical records in the cookie, judging whether the number of the historical records is greater than 1, if so, executing the step 207, otherwise, ending the current flow.
Step 207: and determining the URL with the shortest storage time in the historical record array according to the storage time sequence of each URL in the historical record array, and taking the determined URL as the target URL.
Step 208: and displaying a target webpage corresponding to the target URL, deleting the target URL from the historical record array, and updating the historical record quantity in the cookie.
When the target URL is determined from the history array, whether the history number in the cookie is 1 or not is determined, if the history number is less than 1, the browser is considered to enter the browser for the first time, and at this time, default processing operation is executed, for example, a corresponding first page or other pre-specified pages are opened. If the number of the history records is greater than 1, the last URL in the history record array is used as the target URL, which is URL C.
And after the webpage corresponding to the target URL is displayed, deleting the target URL in the historical record array, and updating the historical record number in the cookie, so that after the user visits the corresponding historical webpage, the corresponding URL is deleted in time, the URLs in the historical record array are managed conveniently, and the user experience is further improved.
As shown in fig. 3, an embodiment of the present invention provides an apparatus for implementing a web page history recording function, including: a URL obtaining unit 301, a URL storing unit 302 and a web page display unit 303; wherein,
the URL obtaining unit 301 is configured to obtain a current uniform resource locator URL of a current web page;
the URL storage unit 302 is configured to store the acquired current URL into a preset history array; wherein the history array is set in a data cookie stored on the user's local terminal;
the web page display unit 303 is configured to obtain a target URL from the history array of the cookie, and display a target web page corresponding to the target URL according to the target URL.
In an embodiment of the present invention, the URL storage unit 302 is configured to pre-store at least one history URL in the history record array, and sort the at least one history URL according to a storage time corresponding to each history URL; determining the last history URL in the sequence according to the sequencing result of the at least one history URL; determining whether the current URL is the same as the last historical URL, if not, storing the current URL in the historical record array;
in an embodiment of the present invention, the URL storage unit 302 is configured to determine a home page identifier of a network home page corresponding to the current webpage, determine whether the home page identifier exists in the current URL, if so, clear the home page identifier, and store the cleared current URL in the history array.
In an embodiment of the present invention, when the number of the history arrays set in the cookie is at least two, the URL storage unit 302 is configured to determine an array identifier corresponding to each history array, analyze the current URL, and determine a feature identifier corresponding to the current URL; determining a historical record array corresponding to the current URL according to the feature identifier and array identifiers respectively corresponding to the historical record arrays; storing the current URL into the determined historical record array;
the webpage display unit 303 is configured to determine a target history record array from at least two history records; and determining the URL with the shortest storage time in the target historical record array according to the storage time sequence of each URL in the target historical record array, and taking the determined URL as the target URL.
As shown in fig. 4, in an embodiment of the present invention, the apparatus may further include: an update unit 401; wherein,
the updating unit 401 is configured to determine the number of URLs in a history array after the URL storing unit 302 stores the acquired current URL in the preset history array, and update the preset history number in the cookie according to the determined number of URLs;
the web page display unit 303 is configured to determine whether the number of history records is greater than a preset threshold, and if so, execute to obtain a target URL from the history record array of the cookie.
Because the information interaction, execution process, and other contents between the units in the device are based on the same concept as the method embodiment of the present invention, specific contents may refer to the description in the method embodiment of the present invention, and are not described herein again.
An embodiment of the present invention further provides a readable medium, which includes an execution instruction, and when a processor of a storage controller executes the execution instruction, the storage controller executes a method provided in any one of the above embodiments of the present invention.
An embodiment of the present invention further provides a storage controller, including: a processor, a memory, and a bus; the memory is used for storing execution instructions, the processor is connected with the memory through the bus, and when the storage controller runs, the processor executes the execution instructions stored in the memory, so that the storage controller executes the method provided by any one of the above embodiments of the invention.
In summary, the above embodiments of the present invention have at least the following advantages:
1. in the embodiment of the invention, after the current URL of the current webpage is acquired, the current URL is stored in the historical record array of the cookie. When the historical record webpage needs to be accessed, the target URL can be obtained from the historical record array of the cookie, and the corresponding target webpage, namely the historical record webpage, is displayed according to the target URL, so that the historical record function of the webpage is realized, and a user can directly jump to other historical record webpages from the currently accessed webpage, so that the user experience is improved.
2. In the embodiment of the invention, when the current URL is different from the last historical URL in the historical record array, the current URL is stored in the historical record array, so that the same URL is prevented from being repeatedly stored, the same webpage is prevented from being returned for multiple times, the selection of the target URL is facilitated, and the user experience is further improved.
3. In the embodiment of the invention, when the home page identifier of the network home page corresponding to the current webpage exists in the current URL, the home page identifier is removed, and the removed current URL is stored in the historical record array, so that the work flow of returning to the historical webpage is reduced, and the realization efficiency of the historical webpage recording function is improved.
4. In the embodiment of the invention, when the number of the historical record arrays set in the cookie is at least two, the array identifier corresponding to each historical record array is determined, the characteristic identifier corresponding to the current URL is determined, the historical record array corresponding to the current URL is determined according to the characteristic identifier and the array identifiers corresponding to the historical record arrays, and the current URL is stored in the determined historical record array. When the operation of returning to the history record is executed, the target history record array is determined, and the URL with the shortest storage market is selected from the target history record array as the target URL, so that the user can conveniently access the webpage with the same characteristic, and the user experience is further improved.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising a" does not exclude the presence of other similar elements in a process, method, article, or apparatus that comprises the element.
Those of ordinary skill in the art will understand that: all or part of the steps for realizing the method embodiments can be completed by hardware related to program instructions, the program can be stored in a computer readable storage medium, and the program executes the steps comprising the method embodiments when executed; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
Finally, it is to be noted that: the above description is only a preferred embodiment of the present invention, and is only used to illustrate the technical solutions of the present invention, and not to limit the protection scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.