A page refresh method and terminal based on Web-side Hash routing change
By adding semantic strings and modifying hash parameters in the Hash routing address, the problem that the page cannot be refreshed when the hash value changes in the Hash routing address is solved, and the efficiency of page update is improved.
Patent Information
- Application Number
- CN202111180301.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-11
- Publication Date
- 2025-03-07
- Estimated Expiration
- 2041-10-11
AI Technical Summary
When changing the hash value in the Hash routing address, the page cannot be refreshed, resulting in inefficient page update.
By adding semantic strings before the # number of the Hash route address, and modifying or adding hash parameters after the # number, a new Hash route address is formed, and then calling the page refresh function to reload the page.
This realizes page refresh when the hash value changes in the Hash routing address, improving the efficiency of page updates.
Smart Images

Figure CN115967672B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of web page loading, and in particular to a page refresh method and terminal based on Web-side Hash routing change. Background Art
[0002] When an external component (such as C++'s CEF window, or Android's Webview) accesses the Web's Hash routing address (such as: http: / / www.test.com / # / page?param=1), after the first access to the routing address page, when the external component needs to modify the routing address parameters for re-access, such as when the user retries, the parameter retry=1 must be added to the url. At this time, the modified address (http: / / www.test.com / # / page?param=1&retry=1) is used to call js's location.reload() or location.replace() and other page refresh functions for the second access. The page will not be refreshed. This is due to the characteristics of the Hash routing address, that is, the content after the # in the Hash routing address (called the hash value) does not refresh the page when it changes.
[0003] In order to solve the problem of changing the hash value of the Hash routing address without refreshing the page, the conventional solutions are as follows: Solution 1: let the Web end change to a non-Hash routing method or notify the Web end to refresh the page. However, the disadvantage of using this solution is that it depends on the modification of the Web end. Another solution is Solution 2: close the current access window (or instance) and reopen it to access the new routing address. Using this solution will deteriorate the user experience. Summary of the invention
[0004] The technical problem to be solved by the present invention is to provide a page refresh method and terminal based on the change of the hash routing on the Web side, so as to solve the problem that the page cannot be refreshed when the hash value in the hash routing address is changed, and improve the efficiency of page refresh.
[0005] In order to solve the above technical problems, the technical solution adopted by the present invention is:
[0006] A page refresh method based on a Web-side Hash route change includes the following steps:
[0007] S1. Parse the URL address of the Web end to obtain the first Hash routing address;
[0008] S2. Add a semantic string before the # sign of the first Hash routing address, and modify or add a hash parameter after the # sign of the first Hash routing address to form a second Hash routing address;
[0009] S3. Call a page refresh function to reload the page corresponding to the second Hash routing address.
[0010] In order to solve the above technical problems, another technical solution provided by the present invention is:
[0011] A page refresh terminal based on a web-side hash routing change includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the following steps are implemented:
[0012] S1. Parse the URL address of the Web end to obtain the first Hash routing address;
[0013] S2. Add a semantic string before the # sign of the first Hash routing address, and modify or add a hash parameter after the # sign of the first Hash routing address to form a second Hash routing address;
[0014] S3. Call a page refresh function to reload the page corresponding to the second Hash routing address.
[0015] The beneficial effect of the present invention is that the present invention provides a page refresh method and terminal based on the change of the hash route on the Web side, by modifying or adding a hash parameter in the hash route address, adding a semantic string between the # signs of the hash route address, and then calling a page refresh function to reload the page of the modified hash route address to achieve page refresh, thereby solving the problem that the page cannot be refreshed when the hash value in the hash route address is changed, and improving the efficiency of page refresh. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 A flow chart of a page refresh method based on a Web-side Hash routing change according to an embodiment of the present invention;
[0017] Figure 2 The present invention is a schematic diagram of a page refresh terminal based on a Web-side Hash routing change according to an embodiment of the present invention.
[0018] Description of labels:
[0019] 1. A page refresh terminal based on a change in a Web-side hash route; 2. A memory; 3. A processor. DETAILED DESCRIPTION
[0020] In order to explain the technical content, achieved objectives and effects of the present invention in detail, the following is an explanation in combination with the implementation modes and the accompanying drawings.
[0021] Please refer to Figure 1 , a page refresh method based on Web-side Hash routing change, comprising the steps of:
[0022] S1. Parse the URL address of the Web end to obtain the first Hash routing address;
[0023] S2. Add a semantic string before the # sign of the first Hash routing address, and modify or add a hash parameter after the # sign of the first Hash routing address to form a second Hash routing address;
[0024] S3. Call a page refresh function to reload the page corresponding to the second Hash routing address.
[0025] From the above description, it can be seen that the beneficial effect of the present invention is that: by modifying or adding hash parameters in the Hash routing address, adding a semantic string between the # signs of the Hash routing address, and then calling the page refresh function to reload the page of the modified Hash routing address to achieve page refresh, the problem of changing the hash value in the Hash routing address but not being able to refresh the page is solved, and the efficiency of page refresh is improved.
[0026] Furthermore, the semantic character string is composed of random numbers and / or timestamps.
[0027] From the above description, it can be known that multiple page refreshes can be achieved by forming any variety of semantic strings using random numbers and / or timestamps.
[0028] Furthermore, in S2, a hash parameter is modified or added after the # sign of the first hash routing address, specifically:
[0029] The ChangeUrl function is used to modify or add the hash parameter after the # sign of the first Hash routing address. The ChangeUrl function is a JavaScript-based URL address conversion function.
[0030] As can be seen from the above description, the user can use the ChangeUrl function to replace the hash parameters required by the new page to be jumped with the hash parameters after the # sign of the original first Hash routing address to modify the URL address parameters.
[0031] Furthermore, the page refresh function is a location.reload() function or a location.replace() function.
[0032] From the above description, we can know that location.reload() and location.replace() are common functions for browsers to refresh pages. The reload method can force the browser to refresh the current page, while the replace method replaces the item currently cached in the history (client) by specifying the URL. The replaced URL cannot be accessed through "forward" and "backward". You can select the corresponding function according to actual needs to realize the refresh of the Hash routing address after modifying the hash parameter.
[0033] Furthermore, before S1, the step of:
[0034] S0. Access the URL address of the Web client for the first time and load the page corresponding to the URL address.
[0035] From the above description, it can be seen that when you visit the Hash routing address for the first time, you can directly enter the corresponding page without refreshing the page.
[0036] Please refer to Figure 2 , a page refresh terminal based on a web-side hash routing change, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:
[0037] S1. Parse the URL address of the Web end to obtain the first Hash routing address;
[0038] S2. Add a semantic string before the # sign of the first Hash routing address, and modify or add a hash parameter after the # sign of the first Hash routing address to form a second Hash routing address;
[0039] S3. Call a page refresh function to reload the page corresponding to the second Hash routing address.
[0040] From the above description, it can be seen that the beneficial effects of the present invention are: based on the same technical concept, in conjunction with the above-mentioned page refresh method based on Web-side Hash routing change, a page refresh terminal based on Web-side Hash routing change is provided, by modifying or adding hash parameters to the Hash routing address, adding a semantic string between the # signs of the Hash routing address, and then calling the page refresh function to reload the page of the modified Hash routing address to achieve page refresh, thereby solving the problem of changing the hash value in the Hash routing address but not being able to refresh the page, and improving the efficiency of page refresh.
[0041] Furthermore, the semantic character string is composed of random numbers and / or timestamps.
[0042] From the above description, it can be known that multiple page refreshes can be achieved by forming any variety of semantic strings using random numbers and / or timestamps.
[0043] Furthermore, in S2, a hash parameter is modified or added after the # sign of the first hash routing address, specifically:
[0044] The ChangeUrl function is used to modify or add the hash parameter after the # sign of the first Hash routing address. The ChangeUrl function is a JavaScript-based URL address conversion function.
[0045] As can be seen from the above description, the user can use the ChangeUrl function to replace the hash parameters required by the new page to be jumped with the hash parameters after the # sign of the original first Hash routing address to modify the URL address parameters.
[0046] Furthermore, the page refresh function is a location.reload() function or a location.replace() function.
[0047] From the above description, we can know that location.reload() and location.replace() are common functions for browsers to refresh pages. The reload method can force the browser to refresh the current page, while the replace method replaces the item currently cached in the history (client) by specifying the URL. The replaced URL cannot be accessed through "forward" and "backward". You can select the corresponding function according to actual needs to realize the refresh of the Hash routing address after modifying the hash parameter.
[0048] Furthermore, before S1, the step of:
[0049] S0. Access the URL address of the Web client for the first time and load the page corresponding to the URL address.
[0050] From the above description, it can be seen that when you visit the Hash routing address for the first time, you can directly enter the corresponding page without refreshing the page.
[0051] Please refer to Figure 1 , Embodiment 1 of the present invention is:
[0052] A page refresh method based on the change of Web-side Hash routing, such as Figure 1 As shown, the steps include:
[0053] S1. Parse the URL address of the Web client and obtain the first Hash routing address.
[0054] S2. Add a semantic string before the # sign of the first Hash routing address, and modify or add a hash parameter after the # sign of the first Hash routing address to form a second Hash routing address;
[0055] The semantic character string is composed of random numbers and / or timestamps, and any variety of semantic character strings can be composed of random numbers and / or timestamps to achieve multiple page refreshes.
[0056] S3. Call the page refresh function to reload the page corresponding to the second Hash routing address.
[0057] That is, in this embodiment, by modifying or adding hash parameters in the Hash routing address, adding a semantic string between the # signs of the Hash routing address, and then calling the page refresh function to reload the page of the modified Hash routing address to achieve page refresh, the problem of changing the hash value in the Hash routing address but not being able to refresh the page is solved, and the efficiency of page refresh is improved.
[0058] Embodiment 2 of the present invention is:
[0059] A page refresh method based on a web-side hash routing change, based on the above embodiment, in this embodiment, before step S1, further includes the following steps:
[0060] S0. Access the URL address of the Web client for the first time and load the page corresponding to the URL address.
[0061] That is, when a user visits the hash routing address for the first time, he can directly enter the corresponding page without refreshing the page.
[0062] Among them, in step S2, the hash parameter is modified or added after the # sign of the first Hash routing address, specifically: the hash parameter after the # sign of the first Hash routing address is modified or added using the ChangeUrl function, and the ChangeUrl function is a JavaScript-based URL address conversion function.
[0063] That is, in this embodiment, the user can use the ChangeUrl function to replace the hash parameter required by the new page to be jumped with the hash parameter after the # sign of the original first Hash routing address to modify the url address parameters. At the same time, in other equivalent embodiments, the change of the Hash routing address can also be realized through other url address parameter modification functions, which can be selected according to the actual operating environment. For example, in the CFE window of C++, the url address can be modified by calling ChangeUrl(url) and in the Android Webview, the url address can be modified by calling webView.loadUrl(url).
[0064] In addition, in this embodiment, the page refresh function in step S3 is the location.reload() function or the location.replace() function, wherein the location.reload() function and the location.replace() function are both common functions for browsers to refresh pages, wherein the reload method can force the browser to refresh the current page, and the replace method replaces the item currently cached in the history (client) by specifying the url, and the replaced url cannot be accessed through "forward" and "backward". In the actual application process, the corresponding function can be selected according to actual needs to realize the refresh of the Hash routing address after modifying the hash parameter. In other equivalent embodiments, the function can also be other page refresh functions except location.reload() and location.replace().
[0065] Please refer to Figure 2 , Embodiment 3 of the present invention is:
[0066] A page refresh terminal 1 based on a Web-side Hash routing change comprises a memory 2, a processor 3, and a computer program stored in the memory 2 and executable on the processor 3. When executing the computer program, the processor 3 implements the steps in a page refresh method based on a Web-side Hash routing change in the above-mentioned embodiment 1 or embodiment 2.
[0067] In summary, the present invention provides a page refresh method and terminal based on Web-side Hash routing change. When a user visits a Hash routing address for the first time, the user can directly enter the corresponding page without refreshing the page. When the Hash routing address needs to be modified and re-accessed, the Changeurl function can be used to replace the hash parameters required for the new page to be jumped with the hash parameters after the # sign of the original Hash routing address to achieve the modification of the url address parameters. While modifying, a semantic string is added between the # signs of the Hash routing address, and then the page refresh function is called to reload the page of the modified Hash routing address to achieve page refresh. This solves the problem that the hash value in the Hash routing address cannot be refreshed, and improves the efficiency of page refresh.
[0068] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent transformations made using the contents of the present invention's specification and drawings, or directly or indirectly applied in related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A page refresh method based on Web-side Hash routing change, characterized in that: Includes steps: S1. Parse the URL address of the Web end to obtain the first Hash routing address; S2. Add a semantic string before the # sign of the first Hash routing address, and modify or add a hash parameter after the # sign of the first Hash routing address to form a second Hash routing address; S3, calling a page refresh function to reload the page corresponding to the second Hash routing address; In S2, a hash parameter is modified or added after the # sign of the first hash routing address, specifically: The ChangeUrl function is used to modify or add the hash parameter after the # sign of the first Hash routing address, and the Changeurl function is a JavaScript-based URL address conversion function.
2. A page refresh method based on Web-side Hash routing change according to claim 1, characterized in that: The semantic character string is composed of random numbers and / or timestamps.
3. A page refresh method based on Web-side Hash routing change according to claim 1, characterized in that: The page refresh function is location.reload() function or location.replace() function.
4. A page refresh method based on Web-side Hash routing change according to claim 1, characterized in that: The step S1 also includes the following steps: S0. Access the URL address of the Web client for the first time and load the page corresponding to the URL address.
5. A page refresh terminal based on Web-side Hash routing change, characterized in that: The invention comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the following steps are implemented: S1. Parse the URL address of the Web end to obtain the first Hash routing address; S2. Add a semantic string before the # sign of the first Hash routing address, and modify or add a hash parameter after the # sign of the first Hash routing address to form a second Hash routing address; S3, calling a page refresh function to reload the page corresponding to the second Hash routing address; In S2, a hash parameter is modified or added after the # sign of the first hash routing address, specifically: The ChangeUrl function is used to modify or add the hash parameter after the # sign of the first Hash routing address. The Changeurl function is a JavaScript-based URL address conversion function.
6. A page refresh terminal based on Web-side Hash routing change according to claim 5, characterized in that: The semantic character string is composed of random numbers and / or timestamps.
7. A page refresh terminal based on Web-side Hash routing change according to claim 5, characterized in that: The page refresh function is location.reload() function or location.replace() function.
8. A page refresh terminal based on Web-side Hash routing change according to claim 5, characterized in that: The step S1 also includes the following steps: S0. Access the URL address of the Web client for the first time and load the page corresponding to the URL address.