CN111708965B - Same-domain single-page-crossing application non-perception skip method and device - Google Patents

Same-domain single-page-crossing application non-perception skip method and device Download PDF

Info

Publication number
CN111708965B
CN111708965B CN202010467872.4A CN202010467872A CN111708965B CN 111708965 B CN111708965 B CN 111708965B CN 202010467872 A CN202010467872 A CN 202010467872A CN 111708965 B CN111708965 B CN 111708965B
Authority
CN
China
Prior art keywords
page
jump
address
target
white list
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010467872.4A
Other languages
Chinese (zh)
Other versions
CN111708965A (en
Inventor
吴江林
崔浩波
孙德华
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Hexuewang Educational Technology Co ltd
Original Assignee
Beijing Hexuewang Educational Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Hexuewang Educational Technology Co ltd filed Critical Beijing Hexuewang Educational Technology Co ltd
Priority to CN202010467872.4A priority Critical patent/CN111708965B/en
Publication of CN111708965A publication Critical patent/CN111708965A/en
Application granted granted Critical
Publication of CN111708965B publication Critical patent/CN111708965B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/955Retrieval from the web using information identifiers, e.g. uniform resource locators [URL]

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The present disclosure provides a method and an apparatus for non-aware skip of single page application across the same domain, which relates to the technical field of computers, and includes: when executing JavaScript code, storing an original push method of a History API in a variable; based on the stored variable construction function, a custom push method of the History API is obtained; based on a custom push method, when a current page needs to jump to a target page, judging whether a jump target address of the target page is matched with a preset white list address; and calling different jump modes according to the matching result, and jumping from the current page to the target page based on the jump modes. The method and the device can effectively reduce development logic and avoid unnecessary errors.

Description

Same-domain single-page-crossing application non-perception skip method and device
Technical Field
The disclosure relates to the technical field of computers, in particular to a method and a device for realizing non-perception skip of single page application in the same domain.
Background
The mutual jump between Web pages is one of the most basic functions of the internet. In the multi-page Web application, a server controls routing, and a new page request is sent to the server to update a current page every time an address bar is changed, and a label or window. Location. Href is used for page jump; in a single-page Web application, a front end controls routing, a new page request is not sent every time an address bar is changed, and page jumping is realized by calling a window/history API, namely, a certain piece of local content on a page is displayed from the current HTML on the premise that only the address bar is changed and the page is not refreshed.
A complex application that is very complex in function may actually consist of a plurality of such subsystems, such as a multi-page Web application and a single-page Web application. When the path jump is changed between the subsystems, the jump mode of the back end control route is mainly adopted; however, single page Web applications are jumped through front end control routing. In view of this, a determination condition is set for each place where it is necessary to skip in page skip for determining whether the path is to skip inside or outside the subsystem. But this approach severely consumes development logic and is prone to errors such as: if the address is determined to be the address which jumps to the outside of the subsystem, but the front-end route jump is used in error, the condition that the page cannot be found occurs.
Disclosure of Invention
In order to solve the technical problems or at least partially solve the technical problems, the present disclosure provides a method and an apparatus for non-aware skip of a single page application across the same domain.
The present disclosure provides a same-domain single-page-crossing application non-aware skip method, comprising: when executing JavaScript code, storing an original push method of a History API in a variable; based on the stored variable construction function, a custom push method of the History API is obtained; based on the self-defined push method, when the current page needs to jump to a target page, judging whether the jump target address of the target page is matched with a preset white list address; and calling different jump modes according to the matching result, and jumping from the current page to the target page based on the jump modes.
Further, the step of calling different jump modes according to the matching result and jumping from the current page to the target page based on the jump modes includes: when the matching result is that the jump target address is matched with a preset white list address, the address of the current page is changed into the jump target path by calling window.
Further, the step of calling different jump modes according to the matching result and jumping from the current page to the target page based on the jump modes includes: when the matching result is that the jump target address is not matched with the preset white list address, the original push method stored in the variable is called to change the address of the current page into the jump target path so as to jump from the current page to the target page.
Further, the method further comprises: setting a valid external-jump white list address through an addition and/or deletion operation; the white list addresses are stored by using a numerical list, and the numerical list is a character string or a regular expression.
Further, the method further comprises: and responding to the user operation, acquiring the target page corresponding to the URL request according to the user operation, and executing JavaScript codes on the target page.
The present disclosure provides a same-domain single-page-crossing application non-aware skip device, comprising: the method storage module is used for storing an original push method of the History API in a variable when the JavaScript code is executed; the method construction module is used for obtaining a custom push method of the History API based on the stored variable construction function; the judging module is used for judging whether the jump target address of the target page is matched with a preset white list address or not when the current page needs to jump to the target page based on the self-defined push method; and the page jumping module is used for calling different jumping modes according to the matching result and jumping from the current page to the target page based on the jumping modes.
Further, the page skip module is further configured to: when the matching result is that the jump target address is matched with a preset white list address, the address of the current page is changed into the jump target path by calling window.
Further, the page skip module is further configured to: when the matching result is that the jump target address is not matched with the preset white list address, the original push method stored in the variable is called to change the address of the current page into the jump target path so as to jump from the current page to the target page.
Further, the apparatus further comprises: the white list setting module is used for setting a valid external jump white list address through adding and/or deleting operations; the white list addresses are stored by using a numerical list, and the numerical list is a character string or a regular expression.
Further, the apparatus further comprises: and the JS execution module is used for responding to user operation, acquiring the target page corresponding to the URL request according to the user operation, and executing JavaScript codes on the target page.
Compared with the prior art, the technical scheme provided by the embodiment of the disclosure has the following advantages:
the disclosure provides a method and a device for realizing non-aware skip of single page application in the same domain, comprising the following steps: when executing JavaScript code, storing an original push method of a History API in a variable; based on the stored variable construction function, a custom push method of the History API is obtained; based on a custom push method, when a current page needs to jump to a target page, judging whether a jump target address of the target page is matched with a preset white list address; and calling different jump modes according to the matching result, and jumping from the current page to the target page based on the jump modes. According to the method and the device, based on the preset white list address, whether the path to be jumped is external or internal can be omitted, and different jump modes are called according to the matching result of the path, and condition judgment is not required to be carried out at all the places where the pages are jumped in the mode, so that development logic can be effectively reduced, and errors which are unnecessarily generated can be avoided.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the disclosure and together with the description, serve to explain the principles of the disclosure.
In order to more clearly illustrate the embodiments of the present disclosure or the solutions in the prior art, the drawings that are required for the description of the embodiments or the prior art will be briefly described below, and it will be obvious to those skilled in the art that other drawings can be obtained from these drawings without inventive effort.
FIG. 1 is a flow chart of a method for implementing a non-aware skip across single pages in a same domain according to an embodiment of the present disclosure;
FIG. 2 is a flowchart of another embodiment of a method for implementing a same-domain skip-over-single-page application with no perceived skip;
fig. 3 is a block diagram of a same-domain single-page application non-aware skip device according to an embodiment of the present disclosure.
Detailed Description
In order that the above objects, features and advantages of the present disclosure may be more clearly understood, a further description of aspects of the present disclosure will be provided below. It should be noted that, without conflict, the embodiments of the present disclosure and features in the embodiments may be combined with each other.
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present disclosure, but the present disclosure may be practiced otherwise than as described herein; it will be apparent that the embodiments in the specification are only some, but not all, embodiments of the disclosure.
The embodiment provides a same-domain single-page application non-aware skip method, and the method mainly comprises the following steps of:
Step S102, when executing JavaScript code, storing an original push method of a History API in a variable;
step S104, obtaining a custom push method of the History API based on the stored variable constructor;
Step S106, based on a self-defined push method, when the current page needs to jump to the target page, judging whether the jump target address of the target page is matched with a preset white list address;
Step S108, calling different jumping modes according to the matching result, and jumping from the current page to the target page based on the jumping modes.
The specific description of this step S108 may refer to step S208 and step S210 in fig. 2.
The same-domain single-page-crossing application non-perception skip method provided by the embodiment can be used for calling different skip modes according to the matching result of the paths without considering whether the paths to be skipped are external or internal based on the preset white list address, and the mode does not need to make condition judgment at all page skip places, so that development logic can be effectively reduced, and errors which are unnecessary to generate can be avoided.
In order to better understand the above-mentioned same-domain single page application non-aware skip method, a scheme provided by the embodiment of the present invention is described in detail below.
Referring to fig. 2, a detailed flowchart of the same-domain single page application non-aware jump method provided in this embodiment is shown, and as shown in fig. 2, the method may include the following steps:
Step S202, when executing JavaScript code, the original push method of the History API is stored in a variable.
In practical application, first, a target page corresponding to a URL request may be obtained according to a user operation in response to the user operation, and JavaScript codes on the target page may be executed. Then when the page starts to execute JavaScript code, the browser History API is modified, that is, the original push method of the History API is stored in a variable.
Step S204, based on the stored variable constructor, the custom push method of the History API is obtained. Specifically, a new function is constructed to cover the original Histroy API push method, and the constructed new function is the custom push method of the History API
Step S206, based on the self-defined push method, when the current page needs to jump to the target page, judging whether the jump target address of the target page is matched with a preset white list address.
In a possible setting manner of the white list address, the effective external jump white list address can be set through adding and/or deleting operation; the user may add a valid user whitelist address, such as by an SQL statement or using the gs_ gucZenith tool, or may delete a user whitelist address that is no longer used using the gs_ gucZenith tool to restrict a given user from accessing the database only from a defined IP. The white list addresses are stored by using a numerical list, and the numerical list is a character string or a regular expression.
For the custom push method after the overlay Histroy API, the logic is specifically as follows: reading an address to be jumped (namely, a jump target address) after the custom Histroy. Push is called; checking whether the jump target address has a matched address in a preset white list address; when the matching result is that the jump target address matches with the preset white list address, the following step S208 is executed; when the matching result is that the jump target address does not match the preset white list address, the following step S210 is executed.
In step S208, the address of the current page is changed to the jump target path by calling window.
Step S210, the address of the current page is changed into a jump target path by calling the original push method stored in the variable, so as to jump from the current page to the target page. Specifically, the History API allows updating of a local content on a page in a script language mode on the premise of not refreshing the page, and switches the address of the current page to a jump target path of the target page so that the displayed page is the target page, thereby realizing the function of switching the current page in the browser to the target page on the premise of not refreshing the page.
The same-domain single-page application non-aware skip method provided by the embodiment can be used for realizing seamless skip control among a plurality of Web single-page applications under the same domain name under the mixed condition of front-end routing and back-end routing. According to the method, the original browser History API function is changed, whether the History API is used for jumping or the window. Location. Href is used for jumping is determined by configuring the external white list address in an incoming mode, and the address replacement is carried out by redirecting the release, so that the generation of redundant address History records can be avoided.
Under the condition of setting a correct white list address, the method can centrally manage which paths jump to an external subsystem, does not need to make condition judgment at all jump switching places, does not need to care whether the paths to be jumped are external or internal, and can reduce development logic and avoid unnecessary errors; in addition, the centralized configuration also facilitates subsequent maintenance.
The embodiment also provides a same-domain single-page application non-aware skip device, which is used for realizing the same-domain single-page application non-aware skip method in the embodiment. Referring to the block diagram of the same domain single page application unaware jump apparatus shown in fig. 3, the apparatus comprises:
The method storing module 302 is configured to store an original push method of the History API in a variable when executing JavaScript code;
The method constructing module 304 is configured to obtain a custom push method of the History API based on the stored variable constructing function;
the judging module 306 is configured to judge, based on a custom push method, whether a jump target address of a target page matches a preset white list address when the current page needs to jump to the target page;
The page skip module 308 is configured to call different skip modes according to the matching result, and skip from the current page to the target page based on the skip modes.
In one embodiment, the page skip module 308 is further configured to:
When the matching result is that the jump target address is matched with the preset white list address, the address of the current page is changed into a jump target path by calling window.
In one embodiment, the page skip module 308 is further configured to:
When the matching result is that the jump target address is not matched with the preset white list address, the address of the current page is changed into a jump target path by calling the original push method stored in the variable, so that the current page is jumped to the target page.
In one embodiment, the above-mentioned same-domain single-page application non-aware skip device further includes:
A whitelist setting module (not shown in the figure) for setting a valid external-jumped whitelist address through an operation of adding and/or deleting; the white list addresses are stored by using a numerical list, and the numerical list is a character string or a regular expression.
In one embodiment, the above-mentioned same-domain single-page application non-aware skip device further includes:
The JS execution module (not shown in the figure) is used for responding to the user operation, acquiring a target page corresponding to the URL request according to the user operation, and executing JavaScript codes on the target page.
The device provided in this embodiment has the same implementation principle and technical effects as those of the foregoing embodiment, and for brevity, reference may be made to the corresponding content in the foregoing method embodiment where no mention is made in this embodiment.
It should be noted that in this document, relational terms such as "first" and "second" and the like are 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. Moreover, 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 one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises an element.
The above is merely a specific embodiment of the disclosure to enable one skilled in the art to understand or practice the disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the disclosure. Thus, the present disclosure is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (6)

1. A method for the same-domain single page crossing application of non-aware jumping, comprising the steps of:
When executing JavaScript code, storing an original push method of a History API in a variable;
Based on the stored variable construction function, a custom push method of the History API is obtained;
Based on the self-defined push method, when the current page needs to jump to a target page, judging whether the jump target address of the target page is matched with a preset white list address;
calling different jump modes according to the matching result, and jumping from the current page to the target page based on the jump modes; the method comprises the following steps:
When the matching result is that the jump target address is not matched with a preset white list address, the address of the current page is changed into the jump target address by calling the original push method stored in a variable so as to jump from the current page to the target page;
When the matching result is that the jump target address is matched with a preset white list address, the address of the current page is changed into the jump target path by calling window.
2. The method according to claim 1, wherein the method further comprises:
Setting a valid external-jump white list address through an addition and/or deletion operation; the white list addresses are stored by using a numerical list, and the numerical list is a character string or a regular expression.
3. The method according to claim 1, wherein the method further comprises:
And responding to the user operation, acquiring the target page corresponding to the URL request according to the user operation, and executing JavaScript codes on the target page.
4. A same-domain single-page-crossing application non-aware skip device, comprising:
the method storage module is used for storing an original push method of the History API in a variable when the JavaScript code is executed;
the method construction module is used for obtaining a custom push method of the History API based on the stored variable construction function;
The judging module is used for judging whether the jump target address of the target page is matched with a preset white list address or not when the current page needs to jump to the target page based on the self-defined push method;
the page jumping module is used for calling different jumping modes according to the matching result and jumping from the current page to the target page based on the jumping modes;
The page jump module is further configured to:
When the matching result is that the jump target address is not matched with a preset white list address, the address of the current page is changed into the jump target address by calling the original push method stored in a variable so as to jump from the current page to the target page;
When the matching result is that the jump target address is matched with a preset white list address, the address of the current page is changed into the jump target path by calling window.
5. The apparatus of claim 4, wherein the apparatus further comprises:
The white list setting module is used for setting a valid external jump white list address through adding and/or deleting operations; the white list addresses are stored by using a numerical list, and the numerical list is a character string or a regular expression.
6. The apparatus of claim 4, wherein the apparatus further comprises:
And the JS execution module is used for responding to user operation, acquiring the target page corresponding to the URL request according to the user operation, and executing JavaScript codes on the target page.
CN202010467872.4A 2020-05-28 2020-05-28 Same-domain single-page-crossing application non-perception skip method and device Active CN111708965B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010467872.4A CN111708965B (en) 2020-05-28 2020-05-28 Same-domain single-page-crossing application non-perception skip method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010467872.4A CN111708965B (en) 2020-05-28 2020-05-28 Same-domain single-page-crossing application non-perception skip method and device

Publications (2)

Publication Number Publication Date
CN111708965A CN111708965A (en) 2020-09-25
CN111708965B true CN111708965B (en) 2024-05-03

Family

ID=72538494

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010467872.4A Active CN111708965B (en) 2020-05-28 2020-05-28 Same-domain single-page-crossing application non-perception skip method and device

Country Status (1)

Country Link
CN (1) CN111708965B (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2017124692A1 (en) * 2016-01-20 2017-07-27 百度在线网络技术(北京)有限公司 Method and apparatus for searching for conversion relationship between form pages and target pages
CN108491206A (en) * 2018-04-12 2018-09-04 江南大学 A kind of SPA single-pages realization method and system
CN109508436A (en) * 2018-11-14 2019-03-22 北京锐安科技有限公司 Front end method for routing and device based on asynchronous loading page
CN110569463A (en) * 2019-08-02 2019-12-13 视联动力信息技术股份有限公司 Page refreshing method and device and storage medium
CN110708368A (en) * 2019-09-25 2020-01-17 北京计算机技术及应用研究所 Micro front-end system and method based on routing distribution
CN110806868A (en) * 2018-08-06 2020-02-18 上海网梯数码科技有限公司 Single-page building and loading method
CN110968824A (en) * 2018-09-30 2020-04-07 北京国双科技有限公司 Page data processing method and device

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2017124692A1 (en) * 2016-01-20 2017-07-27 百度在线网络技术(北京)有限公司 Method and apparatus for searching for conversion relationship between form pages and target pages
CN108491206A (en) * 2018-04-12 2018-09-04 江南大学 A kind of SPA single-pages realization method and system
CN110806868A (en) * 2018-08-06 2020-02-18 上海网梯数码科技有限公司 Single-page building and loading method
CN110968824A (en) * 2018-09-30 2020-04-07 北京国双科技有限公司 Page data processing method and device
CN109508436A (en) * 2018-11-14 2019-03-22 北京锐安科技有限公司 Front end method for routing and device based on asynchronous loading page
CN110569463A (en) * 2019-08-02 2019-12-13 视联动力信息技术股份有限公司 Page refreshing method and device and storage medium
CN110708368A (en) * 2019-09-25 2020-01-17 北京计算机技术及应用研究所 Micro front-end system and method based on routing distribution

Also Published As

Publication number Publication date
CN111708965A (en) 2020-09-25

Similar Documents

Publication Publication Date Title
CN111949351B (en) Page rendering method, device, equipment and computer readable storage medium
JP5863214B2 (en) Storage of web browsing calculations with DOM-based isomorphism
CN101231636B (en) Convenient information search method, system and an input method system
US8082488B2 (en) Method for accessing a parent page while browsing web pages
JP2018517206A (en) Application page quick access
US20180285470A1 (en) A Mobile Web Cache Optimization Method Based on HTML5 Application Caching
US20160171978A1 (en) Voice recognition system and construction method thereof
US20100049842A1 (en) Computing Environment Arranged to Support Predetermined URL Patterns
JP2012522322A (en) Apparatus and method for rendering a page
CN110309461B (en) Page display method and device
CN104182408A (en) Webpage off-line access method and webpage off-line access device
CN111651703B (en) Page jump method and device, electronic equipment and readable storage medium
CN107968841B (en) Dynamic routing method, device, storage medium and client of network page
CN110321503B (en) Web component caching method and device and electronic equipment
CN103577427A (en) Browser kernel based web page crawling method and device and browser containing device
CN110941779A (en) Page loading method and device, storage medium and electronic equipment
CN111708965B (en) Same-domain single-page-crossing application non-perception skip method and device
CN112000690B (en) Method and device for analyzing structured operation statement
US9524076B2 (en) Web page management method and apparatus and storage medium thereof
CN111857934A (en) Page loading method and device, electronic equipment and storage medium
CN104933045A (en) Network information browsing method and network information browsing device
CN110362305B (en) Form component state switching method and device
US20190286438A1 (en) Incorporating version control into packaging
CN104899024A (en) Screenshot method and device
CN115640476A (en) Site column management method, terminal and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant