CN113076501A - Page processing method, storage medium and equipment - Google Patents

Page processing method, storage medium and equipment Download PDF

Info

Publication number
CN113076501A
CN113076501A CN202110432536.0A CN202110432536A CN113076501A CN 113076501 A CN113076501 A CN 113076501A CN 202110432536 A CN202110432536 A CN 202110432536A CN 113076501 A CN113076501 A CN 113076501A
Authority
CN
China
Prior art keywords
page
sub
loaded
code
html file
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.)
Pending
Application number
CN202110432536.0A
Other languages
Chinese (zh)
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.)
Guangzhou Huya Technology Co Ltd
Original Assignee
Guangzhou Huya 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 Guangzhou Huya Technology Co Ltd filed Critical Guangzhou Huya Technology Co Ltd
Priority to CN202110432536.0A priority Critical patent/CN113076501A/en
Publication of CN113076501A publication Critical patent/CN113076501A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING; 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
    • G06F16/972Access to data in other repository systems, e.g. legacy data or dynamic Web page generation
    • GPHYSICS
    • G06COMPUTING; CALCULATING; 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]

Abstract

The method comprises the steps of acquiring an HTML file of a sub-page by using an acquired URL of the sub-page when the sub-page of a current page needs to be loaded, extracting a code segment which cannot be automatically executed during dynamic insertion from the HTML file of the sub-page for storage, and inserting the code of the HTML file of the sub-page into a specified label in a source code of the current page, so that the stored code segment is executed after the code of the HTML file is executed, and the display of the sub-page is realized. Therefore, embedding of the sub-page is achieved under the condition of not depending on the iframe tag, the code of the sub-page is used as a part of the code of the parent page, loading of the sub-page cannot affect loading of the parent page, and accordingly running efficiency of the page and use experience of a user are improved.

Description

Page processing method, storage medium and equipment
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a page processing method, a storage medium, and a device.
Background
When designing a page, there is often a need to nest pages of other URLs within the page. In the related art, nesting of child pages in parent pages is generally implemented by using an iframe tag, which is an HTML (Hyper Text Markup Language) tag that specifies an inline frame for embedding another document in a current HTML document. However, limited to the characteristics of the iframe tag, in a scene using the iframe tag, an onload event that the iframe blocks a parent page often occurs, and multiple loads are caused by the same dependency of parent and child pages, which further causes the page loading speed to become slow, and also affects the use experience of the user.
Disclosure of Invention
To overcome the problems in the related art, the present specification provides a page processing method, a storage medium, and an apparatus.
According to a first aspect of embodiments of the present specification, there is provided a page processing method, including:
in the process of displaying the current page, if a sub-page of the current page needs to be loaded, acquiring a URL (uniform resource locator) of the sub-page;
acquiring an HTML file of the sub-page by using the URL;
searching and storing specified code segments from the HTML file, wherein the specified code segments comprise code segments which cannot be automatically executed when being dynamically inserted;
inserting the code of the HTML file into the designated tag as the element content of the designated tag, and executing the saved designated code segment to display the sub-page after executing the code of the HTML file; wherein the specified tag is a tag in the source code of the current page, and the specified tag includes: block level tags that do not contain the content of the element.
In some examples, the obtaining the HTML file of the sub-page using the URL includes:
and acquiring the HTML file of the sub page by using the URL through a request data interface, wherein the request data interface comprises a Fetch API.
In some examples, the method further comprises:
and if the sub-page needs to be unloaded, removing the code of the HTML file of the sub-page from the specified tag, and restoring the current page to the state before the sub-page is loaded.
In some examples, the restoring the current page to the state before the sub-page is loaded includes:
and restoring the global window object of the current page to the state before the sub-page is loaded.
In some examples, the restoring the global window object of the current page to the state before the sub page is loaded includes:
according to the snapshot of the current page, restoring the global window object of the current page to the state before the sub-page is loaded; the snapshot is created before the HTML file of the sub-page is acquired, and is used for recording the state of the global window object of the current page before the sub-page is loaded.
In some examples, the restoring the current page to the state before the sub-page is loaded includes:
and removing the registration event of the current page, wherein the registration event occurs after the sub-page is loaded.
In some examples, removing the registration event for the current page is performed based on a proxy object created prior to obtaining the HTML file for the sub-page to record the registration event for the current page after the sub-page is loaded.
In some examples, the specified tab is created when the current page first loads a sub-page.
According to a second aspect of embodiments of the present specification, there is provided a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs any one of the methods of the embodiments of the specification.
According to a third aspect of embodiments herein, there is provided a computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements any of the methods in the embodiments herein when executing the program.
The technical scheme provided by the embodiment of the specification can have the following beneficial effects:
in the embodiment of the specification, a page processing method, a storage medium and equipment are disclosed, in the method, when a sub-page of a current page needs to be loaded, an HTML file of the sub-page is acquired by using an acquired URL of the sub-page, a code segment which cannot be automatically executed during dynamic insertion is extracted from the HTML file of the sub-page and is stored, and a code of the HTML file of the sub-page is inserted into a specified tag in a source code of the current page, so that the stored code segment is executed after the code of the HTML file is executed, and the display of the sub-page is realized. Therefore, embedding of the sub-page is achieved under the condition of not depending on the iframe tag, the code of the sub-page is used as a part of the code of the parent page, loading of the sub-page cannot affect loading of the parent page, and accordingly running efficiency of the page and use experience of a user are improved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the specification.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present specification and together with the description, serve to explain the principles of the specification.
FIG. 1 is a flow diagram illustrating a page processing method according to an exemplary embodiment of the present description;
FIG. 2 is a schematic diagram of a sub-page loading process shown in the present specification in accordance with an exemplary embodiment;
FIG. 3 is a schematic diagram of a sub-page unload process shown herein in accordance with an exemplary embodiment;
FIG. 4 is a hardware block diagram of a computer device in which a page processing apparatus is shown according to an example embodiment of the present specification;
fig. 5 is a block diagram of a page processing apparatus shown in the present specification according to an exemplary embodiment.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present specification. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the specification, as detailed in the appended claims.
The terminology used in the description herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the description. As used in this specification and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.
It should be understood that although the terms first, second, third, etc. may be used herein to describe various information, these information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, the first information may also be referred to as second information, and similarly, the second information may also be referred to as first information, without departing from the scope of the present specification. The word "if" as used herein may be interpreted as "at … …" or "when … …" or "in response to a determination", depending on the context.
When page design is performed, there is often a need to nest pages of other URLs in a page, for example, when contents of a plurality of pages are displayed to a client, it is obviously troublesome to display different pages by switching different URLs in a web page address bar, and by page nesting, it is possible to open only one page and then click a corresponding button in the page to display the page content corresponding to the URL of the button. The page and the nested page may be referred to as a parent page and a child page, where the current page is a parent page and the page nested in the parent page is a child page.
In the related art, nesting of child pages in parent pages is generally implemented by using an iframe tag, which is an HTML (Hyper Text Markup Language) tag that specifies an inline frame for embedding another document in a current HTML document. However, some problems affecting the page running efficiency and user experience often occur in a scenario using an iframe tag, for example, the iframe may block onload events of a parent page: the onload event indicates that the current page of the user is loaded completely, when the onload event is loaded and delayed, the onload event gives the user a feeling that the page is very slow, so that the experience is influenced, and the onload event of the father page is triggered only after all iframes are loaded, so that the page loading speed is influenced; as another example, parent-child page identity dependencies result in multiple loads: when a parent page depends on a certain library and a child page also depends on the library, the library is loaded twice in a scene using an iframe tag, so that the page loading speed is reduced, and the flow consumed by a user is increased; besides, the problems that the communication of the parent page and the child page is difficult and the like exist. Based on this, the embodiments of the present disclosure provide a page processing method to solve the above problem.
The following provides a detailed description of examples of the present specification.
The page processing method of the embodiment of the present specification can be applied to an application program having a browser kernel. The browser kernel (Rendering Engine), also called Rendering Engine, is responsible for parsing web page syntax, such as HTML and JavaScript, and Rendering the web page. Existing browser kernels include the Trident kernel, the Gecko kernel, WebKit, and the like. The application may be a browser application, a live application, a shopping application, a game application, and the like, which is not limited in this specification. In the process of displaying the page by the application program, the code file of the page is acquired from the server side providing the page to the local according to the URL of the page, and the page is displayed by reading the code in the code file and executing the code.
As shown in fig. 1, fig. 1 is a flowchart illustrating a page processing method according to an exemplary embodiment, where the method includes:
in the process of displaying the current page in step 101, if a sub-page of the current page needs to be loaded, acquiring a URL of the sub-page;
the current page mentioned in this step may include a front-end page presenting a user interaction interface, such as a report-type page, a search page, a management page, and the like. The current page of the embodiment is taken as a parent page and is provided with at least one sub-page; one or more buttons can be displayed in the current page by using a navigation bar, each button corresponds to a sub-page of a URL, and when an application program detects an event that a user clicks the button, the corresponding sub-page needs to be loaded in the current page. In some examples, the sub-page of the current page may also be automatically loaded, for example, after a preset time threshold for starting loading of the current page, the sub-page of the current page is automatically loaded. Of course, the judgment basis for the sub-page of the current page to be loaded in this step may also be set according to the specific requirements of other scenarios, which is not limited in this specification.
The URL (Uniform Resource Locator), also called a web page address, is an address of a standard Resource on the internet. In this embodiment of the present specification, the URL of the sub page is an address identifier unique to the sub page content in the internet, and through the URL of the sub page, the application program may request the corresponding sub page content from the website server. Since the URL of the sub-page is usually written in the source code of the current page in advance, the step of obtaining the URL of the sub-page may refer to obtaining the URL of the sub-page from the source code of the current page. Of course, the application program may also store a mapping relationship between the trigger event and the URL of the sub-page, and when the trigger event that needs to load a certain sub-page is detected, the URL of the corresponding sub-page is acquired from the mapping relationship.
In step 102, acquiring an HTML file of the sub-page by using the URL;
HTML is a markup language that includes a series of tags by which documents on a network can be formatted in a uniform manner, linking discrete internet resources into a logical whole. The HTML file of the sub page is a file composed of HTML codes and describing the HTML structure of the sub page, and the HTML file of the sub page can illustrate the page contents of the sub page, including characters, graphics, animation, sound, tables or links.
In some examples, this step may be implemented based on a request data interface. The request data Interface is an Interface for exchanging data with a server in the background, such as an XHR (xmlhttprequest) object, which is an API (Application Programming Interface) for transmitting or receiving XML and other data through an Http protocol. Through the XHR object, the request path and the creation request can be determined by using the URL, and the HTML file corresponding to the URL is requested and obtained from the website server. Optionally, the request data interface may include a Fetch API. The Fetch API is an interface proposed by ES6(ecmascript6.0) syntax, and is different from the XHR object in that the Fetch API processes data in a Promise manner. Because the request can be better packaged and transmitted based on the Promise mode, the HTML file corresponding to the URL is acquired through the Fetch API, and the running efficiency of the page can be improved. Of course, in other embodiments, this step may be implemented in other ways, such as a WebView control.
In step 103, searching and storing specified code segments from the HTML file, where the specified code segments include code segments that cannot be automatically executed when dynamically inserted;
different from a scheme of specifying an inline frame for embedding a sub-page by using an iframe tag, in the embodiment of the present specification, after an HTML file of the sub-page is acquired by using a URL of the sub-page, a code of the HTML file of the sub-page is inserted into a source code of a current page, so as to implement loading of the sub-page. The dynamic insertion mentioned in the step refers to a process of inserting other code segments into HTML codes of the page in a code form in the loading process of the page; automatic execution refers to a process in which code fragments are automatically parsed and executed by a browser when a page is loaded. The HTML file of a page often includes a plurality of tags, however, since the code of the sub-page is dynamically inserted into the source code of the current page, generally speaking, not all the code segments corresponding to the tags can be automatically executed. Therefore, in this step, for code fragments that cannot be automatically executed during dynamic insertion, the HTML structure of the sub-page is analyzed by parsing the HTML file, and the code fragments are searched from the HTML structure and then stored in the memory, so that the code fragments are executed independently during subsequent execution of the HTML file.
The designated code segments mentioned in this step may include a code segment corresponding to the style of the sub page and a code segment corresponding to the script of the sub page. Generally speaking, the code segments corresponding to the styles of the sub-pages include code segments corresponding to link tags, and the link tags define the relationship between the document and external resources and are commonly used for linking the CSS style sheet; the code segments of the script corresponding to the sub-page include code segments corresponding to script tags, which are used to define a client-side script, such as JavaScript. It can be understood that the code segments corresponding to the script tag and the link tag which are dynamically inserted cannot be automatically executed, and therefore, the code segments corresponding to the script tag and the link tag are extracted from the HTML file of the sub-page and are independently executed, so that the sub-page can be normally displayed and has a normal style and a page interaction capability.
In step 104, inserting the code of the HTML file into a designated tag as the element content of the designated tag, and executing the saved designated code segment to display the sub-page after executing the code of the HTML file; wherein the specified tag is a tag in the source code of the current page, and the specified tag includes: block level tags that do not contain the content of the element.
HTML tags are the most basic units in the HTML language, and usually appear in pairs, such as < p > and </p >, the first tag in a tag pair is a start tag, the second tag is an end tag, and the content between the start tag and the end tag is called element content, which can also be considered as a child node of the HTML tag. HTML tags are generally divided into block-level tags, also called block elements, and inline tags, also called inline elements, which have the basic difference that both block-level tags start with a new line and inline tags do not monopolize one line. In this embodiment, the designation tag may indicate a location in which the subpage is to be embedded, which includes a block-level tag that does not contain element content, e.g., < div > </div >. It will be appreciated that the block-level tags will occupy an entire line in the document stream, while the inline tags will not, and therefore, using the block-level tags as the designated tags for the code of the HTML file for embedding the subpages can ensure the reasonableness of the layout of the current page layout. It should be noted that the designated tag in this step may be pre-embedded in the source code of the current page by a developer, or may be created by the browser when a sub-page of the current page needs to be loaded, or created by the browser when the sub-page of the current page is loaded for the first time, and the designated tag may be reused when other sub-pages are loaded subsequently, which is not limited in this specification.
Since the designated code segments may include codes of CSS styles and JavaScript scripts corresponding to the sub-pages, and these codes may depend on some elements in other code segments of the HTML file when being executed, after inserting the codes of the HTML file into the position of the designated tag in the source code of the current page, the browser kernel of the application may execute the codes of the HTML file first, and then execute the stored designated code segments, thereby implementing normal display of the sub-pages.
In the page processing method of the embodiment of the present specification, when a sub-page of a current page needs to be loaded, an HTML file of the sub-page is acquired by using an acquired URL of the sub-page, a code segment that cannot be automatically executed when dynamically inserting is extracted from the HTML file of the sub-page and stored, and a code of the HTML file of the sub-page is inserted into a specified tag in a source code of the current page. Therefore, embedding of the child page is achieved without depending on the iframe tag, the code of the child page is used as the element content in the specified tag in the code of the parent page, namely the code of the child page is used as a part of the code of the parent page, loading of the child page cannot block onload events of the parent page, and multiple times of loading cannot be caused when the parent page and the child page depend on the child page.
In practical application, there may be a need to embed several sub-pages in a current page, and when a current page displays a certain sub-page, if another sub-page needs to be loaded, page unloading needs to be performed on the sub-page being displayed first. In the related art using the iframe tag, the corresponding URL in the src attribute of the iframe tag is replaced. To avoid introducing other problems with the use of iframe tags, the present specification correspondingly provides a solution for page uninstallation: in some embodiments, if the sub-page needs to be unloaded, the code of the HTML file of the sub-page is removed from the specified tag, and the current page is restored to the state before the sub-page is loaded. As referred to herein, the need to unload a sub-page may include detecting a page unload event, which may be an event that refreshes or closes the current sub-page, such as closing a browser window, clicking a corresponding button to go to other sub-pages, refreshing the current page, and so forth. When the sub-page needs to be unloaded, removing the code of the HTML file of the sub-page from the specified tag, namely removing the code of the HTML file of the previously inserted sub-page from the source code of the current page; in addition, since the loading process of the sub-page may affect the source code of the current page, the current page needs to be restored to the state before the sub-page is loaded, so as to avoid interference on the subsequent page to be loaded.
When a sub-page is loaded, the global window object may be contaminated by executing code fragments of the script corresponding to the sub-page, and therefore, in some examples, the aforementioned restoring the current page to the state before the sub-page is loaded includes: and restoring the global window object of the current page to the state before the sub-page is loaded. To this point, a snapshot mechanism is introduced in some examples: and creating a snapshot of the current page before the HTML file of the sub-page is acquired, wherein the snapshot of the current page is used for recording the state of the global window object of the current page before the sub-page is loaded. The snapshot of the page refers to that the page is backed up and stored in a cache, when the snapshot of the current page is created, the application program compares the state of the global window object when the page is unloaded with the state of the global window object in the snapshot, and then restores the different global window objects with the comparison result to the state before the sub-page is loaded, so that the pollution of the sub-page loading process to the global window object of the current page is eliminated.
Also, during the process of displaying the sub-page, the current page may generate a registration event, and therefore, in some examples, the aforementioned restoring the current page to the state before the sub-page is loaded includes: and removing the registration event of the current page, wherein the registration event occurs after the sub-page is loaded. The registration event here is a JavaScript event registered on the current page after the sub-page is loaded, such as a click event, a text selection event, a mouse movement event, and the like, which may occur based on the browser behavior or the user behavior. Taking the example that the registration event includes a window scrolling event, after the sub-page is displayed, the user may drag the page through the mouse, so that the current page scrolls to the bottom position, that is, the window scrolling event is generated, and when the sub-page is unloaded, the window scrolling event may be removed, so that the current page is restored to the initial position before the sub-page is loaded. For removal of registration events, a proxy mechanism is introduced in some examples: the removal of the registration event of the current page after the sub-page is loaded is implemented based on a proxy object created before the HTML file of the sub-page is acquired, for recording the registration event of the current page after the sub-page is loaded. Continuing with the previous window scrolling event as an example, the current page monitors the window scrolling event, executes a registration event each time the window is scrolled, and correspondingly, the proxy object records a registration event. The Proxy object may include a Proxy object, which is also a new function proposed by the ES6 and is used to create a Proxy for an object, thereby implementing interception and customization of basic operations (such as attribute lookup, assignment, enumeration, function call, etc.). Accordingly, these registered events can be removed by adding an eventtarget. Therefore, the method for monitoring the event of the current page is proxied through the proxy object, namely the registered events of the current page after the sub-page is loaded are uniformly managed, so that the registered events can be removed by directly utilizing the proxy object when the sub-page is unloaded, and the processing efficiency is improved.
To facilitate a more detailed description of the page processing method of the present specification, a specific embodiment is described below:
the embodiment is applied to a Web application program, and after the Web application program is started, a front page of the Web application program starts to be loaded. The front-end page is nested with two sub-pages, namely a sub-page A and a sub-page B, and in the process of displaying the front-end page, a user can switch and display the contents of the sub-pages through corresponding buttons in the front-end page.
In the process of displaying the front-end page, if it is detected that the sub-page a needs to be loaded, a processing procedure of the Web application is as shown in fig. 2, and includes:
s201, obtaining a URL of a sub-page A;
s202, creating a specified label in the source code of the front-end page, wherein the specified label comprises: a block-level tag that does not contain element content;
s203, creating a snapshot of the front-end page, wherein the snapshot is used for recording the state of the global window object of the front-end page before the sub-page A is loaded;
s204, creating a proxy object, wherein the proxy object is used for recording a subsequent registration event of a front-end page;
s205, acquiring an HTML file of the sub-page A by using the URL of the sub-page A through a Fetch API;
s206, analyzing the HTML file of the sub-page A, and searching and storing the link tag and the code segment corresponding to the script tag, namely the CSS style corresponding to the sub-page A and the code segment of the JavaScript script;
s207, taking the code of the HTML file of the sub-page A as the element content of the designated tag, inserting the code into the position of the designated tag, and executing the stored CSS style corresponding to the sub-page A and the code fragment of the JavaScript script after the HTML file of the sub-page A is executed;
and S208, displaying the sub-page.
Through the steps from S201 to S208, the sub-page A is loaded, the scheme of the iframe tag is replaced, meanwhile, embedding of the front-end page into the sub-page can be completed more efficiently, the running efficiency of the front-end page is improved, and meanwhile, the use experience of a user is also improved.
In the process of displaying the sub-page a, if it is detected that the sub-page B needs to be switched to the loading sub-page B, the sub-page a needs to be unloaded, and then the sub-page B is loaded according to the steps from S201 to S208. For the page unloading of the sub-page a, the processing procedure of the Web application is as shown in fig. 3, and includes:
s301, removing codes of HTML files of the sub-page A from the specified tag;
s302, according to the snapshot of the front-end page, restoring the global window object of the front-end page to the state before the sub-page A is loaded; in the loading process of the sub-page A, a code segment for executing the JavaScript script may pollute a global window object of the front-end page, namely, the state of the global window object of the front-end page is changed, and at the moment, the global window object is different from the snapshot, and the state of the changed window object can be recovered according to comparison;
s303, removing the registration event of the front-end page after the sub-page A is loaded based on the proxy object; similarly, since JavaScript events may be registered during the loading of the sub-page a, the proxy object managing these registration events is used to remove these registration times, so that the front-end page is restored to the state before the sub-page a is loaded.
It should be noted that S301, S302, and S303 do not have a fixed sequence, that is, the Web application may first execute the step of S301, or may first execute the step of S302 or S303.
Through the steps of S301 to S303, the unloading of the sub-page a is realized, so that the preparation work is made for the loading of the sub-page B. Therefore, the switching display of the sub-pages is realized by using the snapshot mechanism and the proxy mechanism, so that the front-end page can be nested with a plurality of sub-pages.
Corresponding to the embodiment of the method, the specification also provides an embodiment of the page processing device and a terminal applied by the page processing device.
The embodiment of the page processing device in the specification can be applied to computer equipment, such as a server or terminal equipment. The device embodiments may be implemented by software, or by hardware, or by a combination of hardware and software. The software implementation is taken as an example, and as a logical device, the device is formed by reading corresponding computer program instructions in the nonvolatile memory into the memory for operation through the processor in which the file processing is located. From a hardware aspect, as shown in fig. 4, which is a hardware structure diagram of a computer device in which a page processing apparatus is located in an embodiment of this specification, except for the processor 410, the memory 430, the network interface 420, and the nonvolatile memory 440 shown in fig. 4, a server or an electronic device in which an apparatus 431 is located in an embodiment may also include other hardware according to an actual function of the computer device, and details of this are not described again.
Accordingly, the embodiments of the present specification also provide a computer storage medium, in which a program is stored, and the program, when executed by a processor, implements the method in any of the above embodiments.
Embodiments of the present description may take the form of a computer program product embodied on one or more storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having program code embodied therein. Computer-usable storage media include permanent and non-permanent, removable and non-removable media, and information storage may be implemented by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of the storage medium of the computer include, but are not limited to: phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technologies, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic tape storage or other magnetic storage devices, or any other non-transmission medium, may be used to store information that may be accessed by a computing device.
As shown in fig. 5, fig. 5 is a block diagram of a page processing apparatus shown in the present specification according to an exemplary embodiment, the apparatus including:
an obtaining module 51, configured to, in a process of displaying a current page, if a sub-page of the current page needs to be loaded, obtain a URL of the sub-page;
a request module 52, configured to obtain an HTML file of the sub-page by using the URL;
a searching module 53, configured to search and store specified code segments from the HTML file, where the specified code segments include code segments that cannot be automatically executed when dynamically inserted;
the execution module 54 is configured to insert the code of the HTML file into the specified tag as the element content of the specified tag, and execute the stored specified code segment after executing the code of the HTML file, so as to display the sub-page; wherein the specified tag is a tag in the source code of the current page, and the specified tag includes: block level tags that do not contain the content of the element.
The implementation process of the functions and actions of each module in the above device is specifically described in the implementation process of the corresponding step in the above method, and is not described herein again.
For the device embodiments, since they substantially correspond to the method embodiments, reference may be made to the partial description of the method embodiments for relevant points. The above-described embodiments of the apparatus are merely illustrative, wherein the modules described as separate parts may or may not be physically separate, and the parts displayed as modules may or may not be physical modules, may be located in one place, or may be distributed on a plurality of network modules. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution in the specification. One of ordinary skill in the art can understand and implement it without inventive effort.
The foregoing description has been directed to specific embodiments of this disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
Other embodiments of the present description will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This specification is intended to cover any variations, uses, or adaptations of the specification following, in general, the principles of the specification and including such departures from the present disclosure as come within known or customary practice within the art to which the specification pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the specification being indicated by the following claims.
It will be understood that the present description is not limited to the precise arrangements described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present description is limited only by the appended claims.
The above description is only a preferred embodiment of the present disclosure, and should not be taken as limiting the present disclosure, and any modifications, equivalents, improvements, etc. made within the spirit and principle of the present disclosure should be included in the scope of the present disclosure.

Claims (10)

1. A page processing method is characterized by comprising the following steps:
in the process of displaying the current page, if a sub-page of the current page needs to be loaded, acquiring a URL (uniform resource locator) of the sub-page;
acquiring an HTML file of the sub-page by using the URL;
searching and storing specified code segments from the HTML file, wherein the specified code segments comprise code segments which cannot be automatically executed when being dynamically inserted;
inserting the code of the HTML file into the designated tag as the element content of the designated tag, and executing the saved designated code segment to display the sub-page after executing the code of the HTML file; wherein the specified tag is a tag in the source code of the current page, and the specified tag includes: block level tags that do not contain the content of the element.
2. The method of claim 1, wherein the obtaining the HTML file of the sub-page using the URL comprises:
and acquiring the HTML file of the sub page by using the URL through a request data interface, wherein the request data interface comprises a Fetch API.
3. The method of claim 1, further comprising:
and if the sub-page needs to be unloaded, removing the code of the HTML file of the sub-page from the specified tag, and restoring the current page to the state before the sub-page is loaded.
4. The method of claim 3, wherein restoring the current page to the state before the sub-page is loaded comprises:
and restoring the global window object of the current page to the state before the sub-page is loaded.
5. The method of claim 4, wherein the restoring the global window object of the current page to the state before the sub-page is loaded comprises:
according to the snapshot of the current page, restoring the global window object of the current page to the state before the sub-page is loaded; the snapshot is created before the HTML file of the sub-page is acquired, and is used for recording the state of the global window object of the current page before the sub-page is loaded.
6. The method of claim 3, wherein restoring the current page to the state before the sub-page is loaded comprises:
and removing the registration event of the current page, wherein the registration event occurs after the sub-page is loaded.
7. The method of claim 6, wherein removing the registration event of the current page is performed based on a proxy object created before the HTML file of the sub-page is obtained for recording the registration event of the current page after the sub-page is loaded.
8. The method of claim 1, wherein the specified tab is created when the current page first loads a sub-page.
9. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor when executing the program implements the method of any one of claims 1 to 8.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1 to 8.
CN202110432536.0A 2021-04-21 2021-04-21 Page processing method, storage medium and equipment Pending CN113076501A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110432536.0A CN113076501A (en) 2021-04-21 2021-04-21 Page processing method, storage medium and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110432536.0A CN113076501A (en) 2021-04-21 2021-04-21 Page processing method, storage medium and equipment

Publications (1)

Publication Number Publication Date
CN113076501A true CN113076501A (en) 2021-07-06

Family

ID=76618285

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110432536.0A Pending CN113076501A (en) 2021-04-21 2021-04-21 Page processing method, storage medium and equipment

Country Status (1)

Country Link
CN (1) CN113076501A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113704669A (en) * 2021-09-01 2021-11-26 稿定(厦门)科技有限公司 Data processing method and device for webpage operation
CN113704668A (en) * 2021-09-01 2021-11-26 稿定(厦门)科技有限公司 Data processing method and device for webpage development

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101685451A (en) * 2008-09-27 2010-03-31 国际商业机器公司 Method for monitoring events in browser, event monitoring device and browser equipment
CN103176972A (en) * 2011-12-20 2013-06-26 富泰华工业(深圳)有限公司 Processing method of browser displaying sub-page and browser
CN103885757A (en) * 2012-12-20 2014-06-25 上海明想电子科技有限公司 Javascript event monitoring management method
US20170193122A1 (en) * 2015-12-31 2017-07-06 Ca, Inc. Dynamic web page navigation
CN110442815A (en) * 2019-06-24 2019-11-12 北京奇艺世纪科技有限公司 Page generation method, system, device and computer readable storage medium
WO2020077681A1 (en) * 2018-10-19 2020-04-23 网宿科技股份有限公司 Method and apparatus for lazy loading of js script
CN111190770A (en) * 2019-12-27 2020-05-22 柏科数据技术(深圳)股份有限公司 COW snapshot technology for data storage and data disaster recovery
CN112637361A (en) * 2020-12-29 2021-04-09 北京天融信网络安全技术有限公司 Page proxy method, device, electronic equipment and storage medium

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101685451A (en) * 2008-09-27 2010-03-31 国际商业机器公司 Method for monitoring events in browser, event monitoring device and browser equipment
CN103176972A (en) * 2011-12-20 2013-06-26 富泰华工业(深圳)有限公司 Processing method of browser displaying sub-page and browser
CN103885757A (en) * 2012-12-20 2014-06-25 上海明想电子科技有限公司 Javascript event monitoring management method
US20170193122A1 (en) * 2015-12-31 2017-07-06 Ca, Inc. Dynamic web page navigation
WO2020077681A1 (en) * 2018-10-19 2020-04-23 网宿科技股份有限公司 Method and apparatus for lazy loading of js script
CN110442815A (en) * 2019-06-24 2019-11-12 北京奇艺世纪科技有限公司 Page generation method, system, device and computer readable storage medium
CN111190770A (en) * 2019-12-27 2020-05-22 柏科数据技术(深圳)股份有限公司 COW snapshot technology for data storage and data disaster recovery
CN112637361A (en) * 2020-12-29 2021-04-09 北京天融信网络安全技术有限公司 Page proxy method, device, electronic equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113704669A (en) * 2021-09-01 2021-11-26 稿定(厦门)科技有限公司 Data processing method and device for webpage operation
CN113704668A (en) * 2021-09-01 2021-11-26 稿定(厦门)科技有限公司 Data processing method and device for webpage development

Similar Documents

Publication Publication Date Title
US9602347B2 (en) Method, system and program for browser to switch IE kernel
US9418243B2 (en) Invoking a private browsing mode by selection of a visual control element within a browser tab
US20130212465A1 (en) Postponed rendering of select web page elements
CN113076501A (en) Page processing method, storage medium and equipment
US20140143644A1 (en) Web browser page transition acceleration
CN105095280B (en) Browser caching method and device
US20140304588A1 (en) Creating page snapshots
US10291738B1 (en) Speculative prefetch of resources across page loads
US20170199850A1 (en) Method and system to decrease page load time by leveraging network latency
US8516041B1 (en) Pre-fetching asynchronously requested content
CN106897347B (en) Webpage display method, operation event recording method and device
CN112637361B (en) Page proxy method, device, electronic equipment and storage medium
CN110442815B (en) Page generation method, system, device and computer readable storage medium
CN110633156B (en) Method and device for associating application program with browser, electronic equipment and storage medium
US20130019152A1 (en) Method and Apparatus for Tracking Exit Destinations of Web Page
CN110209966B (en) Webpage refreshing method, webpage system and electronic equipment
CN114168875A (en) Page program generation method and device, computer equipment and storage medium
CN113742551A (en) Dynamic data capture method based on script and puppeteer
CN112632358B (en) Resource link obtaining method and device, electronic equipment and storage medium
US10769234B2 (en) Document object model transaction crawler
CN107147645B (en) Method and device for acquiring network security data
US11262883B2 (en) Associating browser with application
CN111475748A (en) Picture display method and device
US20140237133A1 (en) Page download control method, system and program for ie core browser
WO2018114055A1 (en) Method and system for providing additional information relating to primary information

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