CN114741158A - Page switching method, device, equipment and storage medium - Google Patents

Page switching method, device, equipment and storage medium Download PDF

Info

Publication number
CN114741158A
CN114741158A CN202210353396.2A CN202210353396A CN114741158A CN 114741158 A CN114741158 A CN 114741158A CN 202210353396 A CN202210353396 A CN 202210353396A CN 114741158 A CN114741158 A CN 114741158A
Authority
CN
China
Prior art keywords
page
file
script
style
data
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
CN202210353396.2A
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.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and 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 Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN202210353396.2A priority Critical patent/CN114741158A/en
Publication of CN114741158A publication Critical patent/CN114741158A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45504Abstract machines for programme code execution, e.g. Java virtual machine [JVM], interpreters, emulators
    • G06F9/45529Embedded in an application, e.g. JavaScript in a Web browser
    • 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]
    • G06F16/9558Details of hyperlinks; Management of linked annotations
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/451Execution arrangements for user interfaces

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Human Computer Interaction (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The disclosure provides a page switching method, a page switching device, page switching equipment, a storage medium and a program product, and relates to the technical field of computers, in particular to the technical field of micro-services. The specific implementation scheme is as follows: responding to a received page switching request aiming at a current page, and acquiring a page file corresponding to the page switching request; determining an external script file and an external style file which are quoted in a page file; injecting script data in the external script file and style data in the external style file into the page file to obtain a target page; and switching the current page to the target page.

Description

Page switching method, device, equipment and storage medium
Technical Field
The present disclosure relates to the field of artificial intelligence technologies, and in particular, to a method, an apparatus, a device, and a storage medium for switching pages.
Background
The front-end technology architecture comprises many technology stacks, such as a progressive framework vue for building a user interface, a scripting language library interact for building a user interface, a front-end framework anglar and a scripting language JavaScript framework jquery for building a user interface, and the like. Pages based on different technology stacks cannot be applied to the same project.
Disclosure of Invention
The disclosure provides a page switching method, device, equipment, storage medium and program product.
According to an aspect of the present disclosure, there is provided a page switching method, including: responding to a received page switching request, and acquiring a page file corresponding to the page switching request; determining an external script file and an external style file which are quoted in the page file; injecting script data in the external script file and style data in the external style file into the page file to obtain a target page; and switching the current page to the target page.
According to another aspect of the present disclosure, there is provided a page switching apparatus including: the acquisition module is used for responding to a received page switching request aiming at a current page and acquiring a page file corresponding to the page switching request; the determining module is used for determining the external script file and the external style file quoted in the page file; the injection module is used for injecting script data in the external script file and style data in the external style file into the page file to obtain a target page; and the switching module is used for switching the current page to the target page.
Another aspect of the present disclosure provides an electronic device including: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of the embodiments of the present disclosure.
According to another aspect of the disclosed embodiments, there is provided a non-transitory computer readable storage medium storing computer instructions for causing a computer to perform the method shown in the disclosed embodiments.
According to another aspect of the embodiments of the present disclosure, there is provided a computer program product comprising computer programs/instructions, characterized in that the computer programs/instructions, when executed by a processor, implement the steps of the method shown in the embodiments of the present disclosure.
It should be understood that the statements in this section do not necessarily identify key or critical features of the embodiments of the present disclosure, nor do they limit the scope of the present disclosure. Other features of the present disclosure will become apparent from the following description.
Drawings
The drawings are included to provide a better understanding of the present solution and are not to be construed as limiting the present disclosure. Wherein:
FIG. 1 is a schematic diagram of an application scenario for page switching according to an embodiment of the present disclosure;
FIG. 2 schematically shows a flow diagram of a page switching method according to an embodiment of the present disclosure;
FIG. 3 schematically illustrates a flow chart of a method of obtaining a pagefile corresponding to a page switch request according to an embodiment of the present disclosure;
FIG. 4 schematically illustrates a flow chart of a method of obtaining a pagefile corresponding to a page switch request according to an embodiment of the present disclosure;
FIG. 5 schematically illustrates a flow chart of a method of injecting script data and style data into a pagefile according to an embodiment of the present disclosure;
FIG. 6 schematically illustrates a flow chart of a method of injecting script data and style data into a pagefile according to an embodiment of the present disclosure;
FIG. 7A schematically illustrates a flow diagram of page switching according to another embodiment of the present disclosure;
FIG. 7B schematically shows a page switch diagram according to another embodiment of the disclosure;
FIG. 8 schematically illustrates a block diagram of a page switching apparatus according to an embodiment of the present disclosure;
FIG. 9 schematically shows a block diagram of an example electronic device that may be used to implement embodiments of the present disclosure.
Detailed Description
Exemplary embodiments of the present disclosure are described below with reference to the accompanying drawings, in which various details of embodiments of the present disclosure are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the present disclosure. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
An application scenario for page switching provided by the present disclosure will be described below with reference to fig. 1.
Fig. 1 is a schematic diagram of an application scenario for page switching according to an embodiment of the present disclosure. It should be noted that fig. 1 is only an example of an application scenario in which the embodiments of the present disclosure may be applied to help those skilled in the art understand the technical content of the present disclosure, and does not mean that the embodiments of the present disclosure may not be applied to other devices, systems, environments or scenarios.
As shown in fig. 1, the application scenario 100 includes a terminal device 101, servers 102, 103, and a network 104. Network 104 is the medium used to provide communication links between terminal device 101 and servers 102, 103. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
A user may use the terminal device 101 to interact with the servers 102, 103 via the network 104 to receive or send messages or the like. Various messaging client applications, such as shopping-like applications, web browser applications, search-like applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only) may be installed on terminal device 101.
The terminal device 101 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The servers 102, 103 may be servers that provide various services, such as a background management server that provides support for websites or applications that users access using the terminal device 101. The background management server may analyze and perform other processing on the received data such as the user request, and feed back a processing result (e.g., a webpage, information, or data obtained or generated according to the user request) to the terminal device.
The servers 102 and 103 may be cloud servers, which are also called cloud computing servers or cloud hosts, and are host products in a cloud computing service system, so as to solve the defects of high management difficulty and weak service extensibility in a conventional physical host and VPS service (Virtual Private Server, or VPS for short). The servers 102, 103 may also be servers of a distributed system or servers that incorporate a blockchain.
According to embodiments of the present disclosure, the servers 102, 103 may each provide support for different websites or applications. The websites or applications supported by the servers 102, 103, respectively, may be based on different technology stacks.
In the related art, since the technology stacks are different, the operating environments required for the pages of the websites or applications supported by the servers 102 and 103 are also different, and thus the pages cannot be operated in the same project. The items may include, for example, application items, website items, and the like.
According to the embodiment of the disclosure, when a user needs to switch to a page based on other technology stacks, a page switching request for a current page may be initiated in the terminal device 101. The terminal device 101 may obtain a page file corresponding to the page switching request, and inject script data and style data referred to in the page file into the page file to obtain a target page. The script data can be used to change the content, properties, styles, elements, etc. of the page file. The style data may be used to set a style of the pagefile. And then converting the current page into a target page. The target page can run without depending on a specific running environment, so that the simultaneous running of a plurality of pages based on different technology stacks in one project can be realized. In addition, according to the page switching method disclosed by the embodiment of the disclosure, a team can be helped to realize the progressive migration of the technology stack.
In addition, during the development process of the application, a plurality of sub-applications independently maintained by a team are accessed into the unified main application. These sub-applications are developed independently, deployed independently, and completely decoupled from each other. With the change of teams, the complexity of the application will be higher and higher, resulting in the application becoming a huge stone application that is difficult to maintain. Based on this, the page switching method according to the embodiment of the present disclosure may be utilized to switch from the page of the main application to the page of the sub application, so that maintainability and readability of the megastone application may be improved.
It should be noted that the page switching method provided by the embodiment of the present disclosure may be generally executed by the terminal device 101. Accordingly, the page switching apparatus provided by the embodiment of the present disclosure may be generally disposed in the terminal device 101. The page switching method provided by the embodiment of the present disclosure may also be executed by other devices that are different from the terminal device 101 and that are capable of communicating with the terminal device 101 and/or the servers 102 and 103. Accordingly, the page switching apparatus provided in the embodiments of the present disclosure may also be disposed in other devices different from the terminal device 101 and capable of communicating with the terminal device 101 and/or the servers 102 and 103.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
In the technical scheme of the disclosure, the collection, storage, use, processing, transmission, provision, disclosure, application and other processing of the personal information of the related user are all in accordance with the regulations of related laws and regulations, necessary confidentiality measures are taken, and the customs of the public order is not violated.
In the technical scheme of the disclosure, before the personal information of the user is acquired or collected, the authorization or the consent of the user is acquired.
The page switching method provided by the present disclosure will be described below with reference to fig. 2.
Fig. 2 schematically shows a flow chart of a page switching method according to an embodiment of the present disclosure.
As shown in fig. 2, the page switching method 200 includes, in response to receiving a page switching request for a current page, acquiring a pagefile corresponding to the page switching request in operation S210.
Then, in operation S220, an external script file and an external style file referenced in the page file are determined.
In operation S230, the script data in the external script file and the style data in the external style file are injected into the page file to obtain a target page.
In operation S240, the current page is switched to the target page.
According to an embodiment of the present disclosure, the page switching request may be used to switch a page of a website or application, for example, may be used to switch a current page to a target page. The page switch request may include a routing address, which may be used to indicate the page intended to be switched. The pagefile may be a file related to the page intended to be switched. The page file may include, for example, a HyperText Markup Language (HTML) file.
According to an embodiment of the present disclosure, the external script file may be a script file used in the page file but located outside the page file. The external script file may be used, for example, to change the content, properties, styles, elements, etc. of the pagefile. The external script file may include, for example, a JavaScript file.
The external style file may be a style file used in the pagefile but located outside the pagefile.
The external style file may be used, for example, to set the style of the pagefile. The external Style files may include, for example, CSS (Cascading Style Sheets) files.
According to the embodiment of the disclosure, the current page and the page file can be obtained based on the same development technology or different development technologies. That is, the technology stacks used for developing the current page and the page file may be the same or different. Development techniques may include, for example, vue, real, anglar, and query, among others.
In the related art, pages based on different technology stacks cannot exist in one project at the same time. The items may include, for example, application items, website items, and the like.
According to an embodiment of the present disclosure, pages based on different technology stacks respectively correspond to different pagefiles. When a page based on other technology stacks needs to be switched, a page file corresponding to the page switching request can be obtained, script data and style data quoted in the page file are injected into the page file to obtain a target page, and then the current page is converted into the target page. Therefore, multiple pages based on different technology stacks can be simultaneously run in one project.
According to an embodiment of the present disclosure, the current page may be, for example, a page of a main application, and the pagefile may be, for example, a pagefile of a sub-application. By generating the target page based on the page file of the sub-application and switching the current page to the target page, the page of the main application can be switched to the page of the sub-application, and the maintainability and readability of the application are improved.
A method for acquiring a page file corresponding to a page switching request provided by the present disclosure will be described below with reference to fig. 3.
Fig. 3 schematically shows a flowchart of a method of acquiring a pagefile corresponding to a page switch request according to an embodiment of the present disclosure.
As shown in fig. 3, the method 310 of acquiring a pagefile corresponding to a page switch request includes determining a sub-website address corresponding to the page switch request in operation S311.
According to an embodiment of the present disclosure, the subnet address may be, for example, a network address corresponding to a page intended to be switched, and may be used to indicate a location of the pagefile.
According to the embodiment of the present disclosure, a routing matching rule may be preset for recording a correspondence between a routing address and a subnet site address. When a page switch request is received, it may be determined whether a routing address in the page switch request hits a route matching rule. If a hit rule is determined, the corresponding subnet site address can be determined from the routing address.
Then, in operation S312, a page fetch request is transmitted to the child website address to fetch the pagefile.
According to the embodiment of the present disclosure, for example, an HTTP (HyperText Transfer Protocol) request may be generated as a page acquisition request according to a subnet address.
Illustratively, in this embodiment, the pagefile may be obtained in a get manner based on the HTTP request. The page file can be obtained by means of HTTP request acquisition, but page rendering is not triggered.
A method for acquiring a page file corresponding to a page switching request provided by the present disclosure will be described below with reference to fig. 4.
Fig. 4 schematically shows a flowchart of a method of acquiring a pagefile corresponding to a page switch request according to an embodiment of the present disclosure.
As shown in fig. 4, the method 420 of acquiring a pagefile corresponding to a page switching request includes determining original link tag data in the pagefile and original script tag data in the pagefile in operation S421.
According to an embodiment of the present disclosure, the original link tag data may be original link tag data in the pagefile. Wherein the link tag data may be used to link the external style file. The original script tag data can be original script tag data in the page file. Wherein the script tag data can be used to link external script files. The original link tag data may include, for example, link tag data and the original script tag data may include, for example, script tag data.
According to an embodiment of the present disclosure, for example, a character string "< link" and the nearest "/>" after the "< link" may be searched in a page file, and data between the "< link" and the "/>" may be determined as original link tag data. For example, the character string "< script" and the most recent "/>" after the "< script" may be searched in the page file, and the data between the "< script" and the "/>" may be determined as the original script tag data.
Then, in operation S422, an external script file referenced in the original script tag data and an external style file referenced in the original link tag data are acquired.
According to an embodiment of the present disclosure, for example, an src attribute in the original script tag data may be determined, where the src attribute is used for the name of the external script file. Then, the file name of the external script file can be obtained according to the value of the src attribute, and then the external script file can be obtained according to the file name.
According to embodiments of the present disclosure, an href attribute in the original link label data may be determined, for example, where the href attribute is used to specify the location of the linked document. Then, the file position of the external style file can be obtained according to the value of the href attribute, and then the external style file is obtained according to the file position.
A method for injecting script data and style data into a page file provided by the present disclosure will be described below with reference to fig. 5.
Fig. 5 schematically shows a flow chart of a method of injecting script data and style data into a pagefile according to an embodiment of the present disclosure.
As shown in fig. 5, the method 530 of injecting script data and style data into a page file includes determining target style tab data according to style data in operation S531.
According to an embodiment of the present disclosure, one or more style label data may be determined as target style label data, for example, from the style data. Wherein the style tab data may be used to set a style of the pagefile. The style label data may include style label data, for example.
Then, the original link tag data in the page file is replaced with the target style tag data in operation S532.
According to an embodiment of the present disclosure, for example, the original link tag data in the pagefile may be deleted, and then the target style tag data may be injected into the pagefile to replace the original link tag data.
According to another embodiment of the present disclosure, for example, the original link tag data in the page file may also be set as an annotation, and then the target style tag data may be injected into the page file to replace the original link tag data.
In operation S533, target script tag data is determined according to the script data.
According to an embodiment of the present disclosure, one or more script tag data may be determined as target script tag data, for example, from script data.
In operation S534, the original script tag data in the page file is replaced with the target script tag data.
According to embodiments of the present disclosure, for example, original script tag data in a page file may be deleted, and then target script tag data may be injected into the page file to replace the original script tag data.
According to another embodiment of the present disclosure, for example, the original script tag data in the page file may also be set as an annotation, and then the target script tag data may be injected into the page file to replace the original script tag data.
A method for injecting script data and style data into a page file provided by the present disclosure will be described below with reference to fig. 6.
Fig. 6 schematically shows a flow chart of a method of injecting script data and style data into a pagefile according to an embodiment of the present disclosure.
As shown in fig. 6, the method 640 of injecting script data and style data into a page file includes acquiring an original execution environment of a current page in operation S641.
In operation S642, a target page is loaded in the original runtime environment.
According to the embodiment of the disclosure, the current page can be completely emptied, and then the target page is loaded.
According to the embodiment of the disclosure, in the process of loading the target page, the running environment of the script data in the target page can be set as the window object in the current running environment, and then the script data in the target page is executed in the current running environment.
According to the embodiment of the disclosure, when the current page performs the predetermined operation with respect to the running environment, the corresponding operation content can be recorded. The predetermined operation may include, for example, operations of adding, deleting, modifying, and querying a global window object attribute, a global listening method, a timer, and the like.
Based on this, acquiring the original running environment of the current page may include, for example, performing a restore operation on the current running environment according to the operation record, that is, restoring the running environment to a state before the operation, so as to obtain the original running environment.
According to further embodiments of the present disclosure, it may also be determined whether image tag data is present in the pagefile. It may be further determined whether the image tag data contains an image relative address in the case where it is determined that the image tag data exists in the page file. The image relative address refers to a file address for locating a referenced image relative to the pagefile itself. And under the condition that the image tag data in the page file contains the image relative address, acquiring the target image according to the image relative address. And then storing the target image to the local according to the relative address of the image. Therefore, the target page can locally acquire the corresponding image and can be executed without depending on a specific running environment.
The page switching method shown above is further described with reference to fig. 7A to 7B in conjunction with specific embodiments. Those skilled in the art will appreciate that the following example embodiments are only for the understanding of the present disclosure, and the present disclosure is not limited thereto.
FIG. 7A schematically shows a flow diagram of page switching according to another embodiment of the present disclosure.
As shown in fig. 7A, according to the embodiment of the present disclosure, a route matching rule of the master website may be set in advance since the correspondence between the route address and the subnet website address is recorded. And when the route switching occurs in the main website, receiving a page switching request. And then determining whether the routing address in the page switching request hits the routing matching rule, if the rule is determined to be hit, determining that the page switching request is intended to be switched to the page of the sub-website, determining the corresponding sub-website address according to the routing address, and then sending a page acquisition request to the corresponding sub-website address.
For example, in the present embodiment, the route matching rule may be as shown in table 1.
Routing address Sub-web site address
xxx.com/A A.com/xxx
xxx.com/B B.com/xxx
TABLE 1
As shown in table 1, when it is determined that the routing address is xxx.com/a, a page acquisition request may be transmitted to the website address a.com/xxx of the sub-website a. com/B, the page acquisition request may be transmitted to a website address b.com/xxx of the sub-website B.
According to the embodiment of the disclosure, the link tag data and the script tag data in the HTTP file can be acquired, and then the link tag data and the script tag data in the HTTP file are set as annotations, so that the reconstructed HTTP file is obtained.
Next, the external style file links in all the link label data may be acquired, and an external style file link set is obtained. And respectively aiming at each link in the link set of the external style file, acquiring the external style file quoted in the link label data to obtain all style code contents in the external style file, namely style data. In addition, external script file links in all script tag data can be acquired, and an external script file link set is obtained. And respectively aiming at each link in the external script file link set, acquiring the external script file quoted in the script tag data, and obtaining all script code contents in the external script file, namely script data.
Next, the link tag data set as an annotation in the previous HTML file may be replaced with style tag data, and corresponding style code content is injected into the style tag data, thereby converting the external style into the inline style. In addition, script tag data set as a comment in the HTML file may be replaced with script code content.
The host then empties the content of the current page, restoring the operating environment of the current page 750. And the main website loads the acquired and processed HTML files of the sub-websites. And setting the execution context of the script file in the HTML file as a window object of the main website, and executing the sub-website script file.
Fig. 7B schematically shows a page switching diagram according to another embodiment of the present disclosure.
As shown in fig. 7B, the link tag data 721 and the script tag data 722 in the HTTP file 710 may be acquired and cached within a specified space, and then the link tag data 721 and the script tag data 722 in the HTTP file 710 may be set as annotations.
Next, the external style file links in all the link label data 721 may be acquired, resulting in an external style file link set. The external style file 731 referenced in the link tag data 721 is acquired by an HTTP request for each link in the external style file link set, respectively, resulting in all style code contents, i.e., style data, in the external style file 731. Among them, the external style file 732 may be a CSS file. In addition, all external script file links in the script tag data 721 may be obtained, resulting in an external script file link set. The external script file 732 referred to in the script tag data 731 is obtained by an HTTP request for each link in the external script file link set, respectively, to obtain all script code contents, i.e., script data, in the external script file 732. The external script file 732 may be a JavaScript file. Also, image tag data (img tag data) 723 having a relative address in the HTML file 710 is acquired, and an image (image)733 referred to in the image tag data 723 is downloaded and then stored locally.
Next, the external style may be converted into an inline style by circularly traversing the HTML file 710, replacing the link tag data 721 set as an annotation in the HTML file 710 with style tag data, and injecting corresponding style code content into the style tag data. Because the path of the external CSS file is a relative path, converting the external style into the inline style can avoid the inability to acquire the external CSS file. In addition, the script tag data 731 set as a comment in the HTML file 710 may be replaced with script code content. The execution context of the script data can then be set as needed to expose the script execution method to the outside. After the above processing, the HTML file 740 of the sub-website is obtained.
Next, the host website empties the content of the current page 750, i.e., the HTML content. The host website restores the running environment of the current page 750, including operations of restoring the global window object attribute, a global monitoring method, adding, deleting, modifying, checking and the like of a timer. The host website loads the HTML files 740 of the child websites that were acquired and processed. The corresponding image is read locally during the loading process and displayed at the corresponding position of the HTML file 740. In addition, the runtime environment of the script file in the HTML file 740 is set to be the window object of the main website, and the sub-website script file is executed.
According to the method for switching the page, the page file corresponding to the page switching request is obtained, script data and style data quoted in the page file are injected into the page file to obtain the target page, and then the current page is converted into the target page. Therefore, multiple pages based on different technology stacks can be simultaneously run in one project. In addition, the method of switching pages according to the embodiment of the present disclosure may also be used to improve maintainability and readability of an application.
The page switching apparatus provided by the present disclosure will be described below with reference to fig. 8.
Fig. 8 schematically shows a block diagram of a page switching apparatus according to an embodiment of the present disclosure.
As shown in fig. 8, the page switching apparatus 800 includes an obtaining module 810, a determining module 820, an injecting module 830, and a switching module 840.
The obtaining module 810 is configured to, in response to receiving a page switching request for a current page, obtain a page file corresponding to the page switching request.
A determining module 820 for determining the external script file and the external style file referenced in the page file.
And the injection module 830 is configured to inject the script data in the external script file and the style data in the external style file into the page file to obtain a target page.
A switching module 840, configured to switch the current page to the target page.
The present disclosure also provides an electronic device, a readable storage medium, and a computer program product according to embodiments of the present disclosure.
FIG. 9 schematically shows a block diagram of an example electronic device 900 that may be used to implement embodiments of the present disclosure. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be examples only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 9, the apparatus 900 includes a computing unit 901 which can perform various appropriate actions and processes in accordance with a computer program stored in a Read Only Memory (ROM)902 or a computer program loaded from a storage unit 908 into a Random Access Memory (RAM) 903. In the RAM 903, various programs and data required for the operation of the device 900 can also be stored. The calculation unit 901, ROM 902, and RAM 903 are connected to each other via a bus 904. An input/output (I/O) interface 905 is also connected to bus 904.
A number of components in the device 900 are connected to the I/O interface 905, including: an input unit 906 such as a keyboard, a mouse, and the like; an output unit 907 such as various types of displays, speakers, and the like; a storage unit 908 such as a magnetic disk, optical disk, or the like; and a communication unit 909 such as a network card, a modem, a wireless communication transceiver, and the like. The communication unit 909 allows the device 900 to exchange information/data with other devices through a computer network such as the internet and/or various telecommunication networks.
The computing unit 901 may be a variety of general and/or special purpose processing components with processing and computing capabilities. Some examples of the computing unit 901 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various dedicated Artificial Intelligence (AI) computing chips, various computing units running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, and so forth. The computing unit 901 performs the respective methods and processes described above, such as a page switching method. For example, in some embodiments, the page switching method may be implemented as a computer software program tangibly embodied in a machine-readable medium, such as storage unit 908. In some embodiments, part or all of the computer program may be loaded and/or installed onto device 900 via ROM 902 and/or communications unit 909. When the computer program is loaded into the RAM 903 and executed by the computing unit 901, one or more steps of the page switching method described above may be performed. Alternatively, in other embodiments, the computing unit 901 may be configured to perform the page switching method by any other suitable means (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuitry, Field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), system on a chip (SOCs), Complex Programmable Logic Devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, receiving data and instructions from, and transmitting data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for implementing the methods of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the program codes, when executed by the processor or controller, cause the functions/operations specified in the flowchart and/or block diagram to be performed. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic, speech, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a back-end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), Wide Area Networks (WANs), and the Internet.
The computer system may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other.
It should be understood that various forms of the flows shown above may be used, with steps reordered, added, or deleted. For example, the steps described in the present disclosure may be executed in parallel, sequentially, or in different orders, as long as the desired results of the technical solutions disclosed in the present disclosure can be achieved, and the present disclosure is not limited herein.
The above detailed description should not be construed as limiting the scope of the disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may be made in accordance with design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present disclosure should be included in the scope of protection of the present disclosure.

Claims (13)

1. A page switching method comprises the following steps:
responding to a received page switching request aiming at a current page, and acquiring a page file corresponding to the page switching request;
determining an external script file and an external style file which are quoted in the page file;
injecting script data in the external script file and style data in the external style file into the page file to obtain a target page; and
and switching the current page to the target page.
2. The method of claim 1, wherein the obtaining the pagefile corresponding to the page switch request comprises:
determining the address of the sub-network station corresponding to the page switching request; and
and sending a page acquisition request to the sub-website address so as to acquire the page file.
3. The method of claim 2, further comprising:
and generating a hypertext transfer protocol request as the page acquisition request according to the subnet station address.
4. The method of claim 1, wherein the determining the external script file and the external style file referenced in the pagefile comprises:
determining original link tag data in the page file and original script tag data in the page file; and
and acquiring an external script file quoted in the original script tag data and an external style file quoted in the original link tag data.
5. The method according to claim 1, wherein said injecting script data in the external script file and style data in the external style file into the page file to obtain a target page comprises:
determining target style label data according to the style data;
replacing the original link tag data in the page file with the target style tag data;
determining target script tag data according to the script data; and
and replacing the original script tag data in the page file with the target script tag data.
6. The method of claim 1, wherein the switching the current page to the target page comprises:
acquiring an original operation environment of the current page; and
and loading the target page in the original operation environment.
7. The method of claim 6, further comprising:
recording an operation record aiming at the running environment received by the current page;
wherein the acquiring of the original operating environment of the current page includes:
and performing reduction operation on the current operating environment according to the operation record to obtain the original operating environment.
8. The method of claim 1, further comprising:
under the condition that the image tag data in the page file contain the image relative address, acquiring a target image according to the image relative address; and
and storing the target image to the local according to the image relative address.
9. The method of any of claims 1-8, wherein the current page and the pagefile are based on different development technologies.
10. A page switching apparatus comprising:
the acquisition module is used for responding to a received page switching request aiming at a current page and acquiring a page file corresponding to the page switching request;
the determining module is used for determining the external script file and the external style file quoted in the page file;
the injection module is used for injecting script data in the external script file and style data in the external style file into the page file to obtain a target page; and
and the switching module is used for switching the current page to the target page.
11. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein, the first and the second end of the pipe are connected with each other,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-9.
12. A non-transitory computer readable storage medium having stored thereon computer instructions for causing the computer to perform the method of any one of claims 1-9.
13. A computer program product comprising computer program/instructions, characterized in that the computer program/instructions, when executed by a processor, implement the steps of the method of any of claims 1-9.
CN202210353396.2A 2022-04-02 2022-04-02 Page switching method, device, equipment and storage medium Pending CN114741158A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210353396.2A CN114741158A (en) 2022-04-02 2022-04-02 Page switching method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210353396.2A CN114741158A (en) 2022-04-02 2022-04-02 Page switching method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114741158A true CN114741158A (en) 2022-07-12

Family

ID=82278588

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210353396.2A Pending CN114741158A (en) 2022-04-02 2022-04-02 Page switching method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114741158A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115577200A (en) * 2022-09-28 2023-01-06 北京百度网讯科技有限公司 Page loading method, device, equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115577200A (en) * 2022-09-28 2023-01-06 北京百度网讯科技有限公司 Page loading method, device, equipment and storage medium
CN115577200B (en) * 2022-09-28 2024-04-23 北京百度网讯科技有限公司 Page loading method, device, equipment and storage medium

Similar Documents

Publication Publication Date Title
CN110858172A (en) Automatic test code generation method and device
CN113010827B (en) Page rendering method and device, electronic equipment and storage medium
CN112685671A (en) Page display method, device, equipment and storage medium
CN113382083A (en) Webpage screenshot method and device
CN112860356A (en) API call control method and device, electronic equipment and storage medium
US11477158B2 (en) Method and apparatus for advertisement anti-blocking
CN114741158A (en) Page switching method, device, equipment and storage medium
CN111831536A (en) Automatic testing method and device
US11662927B2 (en) Redirecting access requests between access engines of respective disk management devices
CN111858621A (en) Method, device, equipment and computer readable medium for monitoring business process
CN111176982B (en) Test interface generation method and device
CN114861097A (en) Browser caching method and device, electronic equipment and storage medium
CN114417070A (en) Method, device and equipment for converging data authority and storage medium
CN113656737A (en) Webpage content display method and device, electronic equipment and storage medium
CN113420037B (en) Asset data real-time changing method and device
CN111767486A (en) Method, device, electronic equipment and computer readable medium for displaying page
CN112925573B (en) Method, device, equipment and computer readable medium for loading web page
CN111290870A (en) Method and device for detecting abnormity
CN112965747B (en) Method, apparatus, device and computer readable medium for mining code loopholes
CN113836173B (en) Data processing method and device, electronic equipment and storage medium
CN113411800B (en) Method and device for assisting client in wireless network switching
CN115344801A (en) Method, device, equipment and medium for updating webpage link
CN113449215A (en) Method and device for loading picture
CN113849170A (en) Code sharing method and device, electronic equipment and storage medium
CN113642295A (en) Page layout method, page layout device and computer program product

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