Protocol display method and device, electronic equipment and storage medium

By directly rendering the HTML-format web protocol document in the web page view container, the inefficiency and garbled code problems caused by format conversion in the prior art are solved, and efficient protocol display is achieved.

CN120104903APending Publication Date: 2025-06-06SHENZHEN LEXIN SOFTWARE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510103121.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-22
Publication Date
2025-06-06

AI Technical Summary

Technical Problem

The prior art requires format conversion in the display of web page protocols, resulting in a reduced efficiency of protocol display.

Method used

By obtaining the protocol link of the web page protocol, the document format is determined based on the suffix. If it is the first preset format (such as HTML), a partition tag and document object model tree is created, the protocol document is requested and the tree structure is updated, and the rendering is directly in the web page view container to avoid format conversion.

Benefits of technology

It improves the efficiency of the head and tail splicing display of the web protocol, avoids the garbled problem caused by mismatch in style and encoding, and realizes rapid rendering of HTML documents.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120104903A_ABST
    Figure CN120104903A_ABST
Patent Text Reader

Abstract

The invention provides a protocol display method and device, electronic equipment and a storage medium, and relates to the technical field of webpage content display, and the method comprises the following steps: aiming at a webpage protocol of which the document format is a first preset format, creating a partition label in a webpage view container, and creating a first document object model tree by taking the partition label as a root node; and then requesting a protocol document of a webpage protocol by utilizing a protocol link to obtain a request result of the protocol document, updating the first document object model tree according to the request result, and rendering a document in a first preset format including an HTML format into a webpage view container by rendering the updated first document object model tree. In this way, the protocol documents of different webpage protocols are sequentially rendered into the webpage view container in an end-to-end splicing mode. In this way, format conversion does not need to be carried out when the document in the HTML format is rendered, independent rendering of the document in the HTML format is achieved in the webpage view container, and the efficiency of webpage protocol head-to-tail splicing display is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of web page content display, and in particular to a protocol display method, device, electronic device and storage medium. Background Art

[0002] In various scenarios such as user registration of new accounts, business processing, electronic contract signing, etc., in order to enhance the compliance, reliability and legal effect of the process, it is often necessary to display some agreement terms to users. This process involves the display method of web page agreements.

[0003] Currently, most webview containers with a fixed height are used to display a web protocol document. Users can browse different protocols by clicking on the tab switch. However, this method has poor user experience and compliance issues. Therefore, a protocol display solution that is connected end to end is gradually proposed.

[0004] In most financial transaction scenarios, such as when users apply for loans or purchase different financial products on financial transaction platforms, different businesses involve different agreement terms, and the formats of network protocols that need to be displayed are also diverse, such as PDF, HTML and other formats.

[0005] Since PDF.js used to render PDF documents is tightly integrated with the JavaScript engine of WebView, the style, encoding, and rendering of PDF files can be kept consistent with those of web pages. Currently, the method of displaying web protocols end to end is often to convert HTML protocols into PDF protocols and then display the protocol documents in PDF format in the web view container.

[0006] However, this method requires that the format conversion be uniformly performed before the protocol documents of the web page protocol are rendered and displayed, which reduces the efficiency of protocol display. Summary of the invention

[0007] Based on this, it is necessary to provide a protocol display method, device, electronic device and storage medium to address the above technical problems, so as to improve the efficiency of protocol display.

[0008] A protocol display method, the method comprising: Obtain protocol links of multiple web page protocols that need to be displayed; Determine the document format of the web page protocol according to the suffix of the protocol link; Determining whether the document format is a first preset format; the first preset format represents a document format that can be parsed into a document object model tree structure; If yes, create a partition label at the highest display position in the current web page view container; Creating a first document object model tree with the partition tag as a root node; Utilizing the protocol link, requesting the protocol document of the webpage protocol, and obtaining a request result of the protocol document; According to the request result, updating the first document object model tree to obtain a target document object model tree; By rendering the target document object model tree in the web page view container, the protocol document of the web page protocol is rendered into the web page view container, so that the protocol documents of different web page protocols are sequentially rendered into the web page view container in a head-to-tail manner.

[0009] In an embodiment of the present application, updating the first document object model tree according to the request result to obtain a target document object model tree includes: Determine whether the request result includes information that the request is successful; If the request result includes information indicating a successful request, encapsulating the protocol document included in the request result into a first target tree structure; The tree structure of the first document object model tree is updated to the first target tree structure; and the updated first document object model tree is used as the target document object model tree.

[0010] In an embodiment of the present application, updating the first document object model tree according to the request result to obtain a target document object model tree includes: Determine whether the request result includes information that the request is successful; If the request result includes information indicating a successful request, encapsulating the protocol document included in the request result into a first target tree structure; Updating the tree structure of the first document object model tree to the first target tree structure; Parsing the header metadata information of the protocol document to determine whether the protocol document is obtained after format conversion of a document in a second preset format; the second preset format represents the format of an editable document; If the protocol document is obtained by format conversion of a document in a second preset format, pre-rendering the updated first document object model tree in the web page view container to pre-render the protocol document into the web page view container; Obtaining the display height of the protocol document in the web page view container, and clearing the pre-rendered display content; Creating an inline frame tag, assigning the display height to a height attribute of the inline frame tag, and assigning the protocol link to a source attribute of the inline frame tag; Encapsulating the assigned inline frame tag into a second target tree structure; The first target tree structure of the first document object model tree is replaced with the second target tree structure; and the first document object model tree after the tree structure is replaced is used as the target document object model tree.

[0011] In the embodiment of the present application, after parsing the header metadata information of the protocol document and determining whether the protocol document is obtained after format conversion of a document in a second preset format, the method further includes: If the protocol document is not obtained after format conversion of a document in a second preset format, the updated first object model tree is used as the target document object model tree.

[0012] In the embodiment of the present application, after determining whether the request result includes information that the request is successful, the method further includes: If the request result does not include information that the request is successful, an inline frame tag is created, and the protocol link is assigned to a source attribute of the inline frame tag, and a preset display height is assigned to a height attribute of the inline frame tag; Encapsulating the assigned inline frame tag into a third target tree structure; The tree structure of the first document object model tree is updated to the third target tree structure; and the updated first document object model tree is used as the target document object model tree.

[0013] In the embodiment of the present application, after determining whether the document format is the first preset format, the method further includes: If not, a third-party parsing library corresponding to the document format is called to render the protocol document into the web page view container.

[0014] In the embodiment of the present application, the step of obtaining protocol links of multiple web page protocols to be displayed includes: After detecting that a marked page is displayed on the front end, obtaining a user identifier associated with the marked page; the marked page represents a front end page for triggering the display of a web page protocol; Filtering unread protocols corresponding to the user identifier from all web page protocols that need to be displayed to the user; Get the agreement link of the unread agreement.

[0015] A protocol display device, the device comprising: A first acquisition module, used for acquiring protocol links of multiple web page protocols to be displayed; A determination module, used to determine the document format of the web page protocol according to the suffix of the protocol link; A determination module, configured to determine whether the document format is a first preset format; the first preset format represents a document format that can be parsed into a document object model tree structure; A first creation module is used to create a partition label at the highest display position in the current web page view container if yes; A second creation module, used to create a first document object model tree with the partition tag as a root node; A second acquisition module, used to request a protocol document of the webpage protocol using the protocol link, and obtain a request result of the protocol document; An updating module, used for updating the first document object model tree according to the request result to obtain a target document object model tree; A rendering module is used to render the target document object model tree in the web page view container to render the protocol document of the web page protocol into the web page view container, so as to render the protocol documents of different web page protocols into the web page view container in sequence.

[0016] In the embodiment of the present application, the update module is used to: Determine whether the request result includes information that the request is successful; If the request result includes information indicating a successful request, encapsulating the protocol document included in the request result into a first target tree structure; The tree structure of the first document object model tree is updated to the first target tree structure; and the updated first document object model tree is used as the target document object model tree.

[0017] In the embodiment of the present application, the update module is used to: Determine whether the request result includes information that the request is successful; If the request result includes information indicating a successful request, encapsulating the protocol document included in the request result into a first target tree structure; Updating the tree structure of the first document object model tree to the first target tree structure; Parsing the header metadata information of the protocol document to determine whether the protocol document is obtained after format conversion of a document in a second preset format; If the protocol document is obtained by format conversion of a document in a second preset format, pre-rendering the updated first document object model tree in the web page view container to pre-render the protocol document into the web page view container; Obtaining the display height of the protocol document in the web page view container, and clearing the pre-rendered display content; Creating an inline frame tag, assigning the display height to a height attribute of the inline frame tag, and assigning the protocol link to a source attribute of the inline frame tag; Encapsulating the assigned inline frame tag into a second target tree structure; The first target tree structure of the first document object model tree is replaced with the second target tree structure; and the first document object model tree after the tree structure is replaced is used as the target document object model tree.

[0018] In an embodiment of the present application, the updating module, after parsing the header metadata information of the protocol document and determining whether the protocol document is obtained after format conversion of a document in a second preset format, is further configured to: If the protocol document is not obtained after format conversion of a document in a second preset format, the updated first document object model tree is used as the target document object model tree.

[0019] In the embodiment of the present application, the update module is further used to: If the request result does not include information that the request is successful, an inline frame tag is created, and the protocol link is assigned to a source attribute of the inline frame tag, and a preset display height is assigned to a height attribute of the inline frame tag; Encapsulating the assigned inline frame tag into a third target tree structure; The tree structure of the first document object model tree is updated to the third target tree structure; and the updated first document object model tree is used as the target document object model tree.

[0020] In the embodiment of the present application, after determining whether the document format is the first preset format, the device is further configured to: If not, call the third-party parsing library corresponding to the document format, and use the highest display position and the protocol link as input data when calling the third-party parsing library, so that the third-party parsing library loads the protocol document according to the protocol link and starts rendering the protocol document from the highest display position.

[0021] In the embodiment of the present application, the acquisition module is used to: After detecting that a marked page is displayed on the front end, obtaining a user identifier associated with the marked page; the marked page represents a front end page for triggering the display of a web page protocol; Filtering unread protocols corresponding to the user identifier from all web page protocols that need to be displayed to the user; Get the agreement link of the unread agreement.

[0022] An electronic device comprises a memory, a processor and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the protocol display method described in the above embodiment are implemented.

[0023] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the protocol display method described in the above embodiment.

[0024] In summary, the present application proposes a protocol display method, device, electronic device and storage medium. After obtaining the protocol link of the web page protocol to be displayed, the method first determines the document format of the web page protocol according to the suffix of the protocol link. If the document format of the web page protocol is a first preset format that can be parsed into a document object model tree structure, a partition tag is first created in the web page view container, and a first document object model tree is created with the partition tag as the root node. Then, the protocol link is used to request the protocol document of the web page protocol to obtain the request result of the protocol document. According to the request result, the first document object model tree is updated to obtain a target document object model tree. By rendering the target document object model tree in the web page view container, the document in the first preset format is rendered into the web page view container. In this way, the protocol documents of different web pages can be rendered into the web page view container in sequence. In this way, when rendering documents in the first preset format, including HTML format, format conversion is no longer required. By establishing a document object model tree capable of isolating styles for the documents in the first preset format, independent rendering of the documents in the first preset format is achieved in the web page view container, thereby avoiding garbled characters due to mismatched styles or encoding methods during the rendering process. HTML documents can be quickly rendered into the web page view container, improving the efficiency of the head-to-tail splicing display of web page protocols. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.

[0026] Figure 1 is a flowchart of a protocol display method according to an exemplary embodiment of the present application; Figure 2 is a flowchart of a protocol display method according to an exemplary embodiment of the present application; Figure 3 is a flowchart of a protocol display method according to another exemplary embodiment of the present application; Figure 4 is a flowchart of a protocol display method according to another exemplary embodiment of the present application; Figure 5 is a schematic block diagram of a protocol display device according to another exemplary embodiment of the present application; Figure 6 It is a schematic block diagram of an electronic device according to an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0027] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. The embodiments described by reference to the drawings are exemplary and are intended to be used to explain the present application, and cannot be understood as limiting the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0028] Figure 1 is a flowchart of a protocol display method according to an exemplary embodiment of the present application. Figure 1 As shown, the protocol display method includes the following steps: S101, obtaining protocol links of multiple web page protocols that need to be displayed.

[0029] Web page protocols may be stored locally or from the Internet.

[0030] The protocol link of a web protocol points to the storage address of the protocol document of the web protocol or the network address where the protocol document can be obtained. This link is usually a URL. URL (Uniform Resource Locator) is a character sequence used to identify and locate resources on the Internet. URL is mainly used to identify and locate web pages, images, files, services and other types of resources on the Web.

[0031] In some embodiments, before obtaining the protocol document, some key information may be obtained by parsing the protocol link, such as the protocol type, server address, document path, etc. The URL of the acquisition request is constructed based on this information.

[0032] Among them, protocol links of different web page protocols may be provided by different third parties. The protocol links provided by these third parties often point to the servers or resources of the third parties.

[0033] For example, a financial product involves multiple investors. Before a user purchases the financial product, the user needs to read and agree to the terms of agreement provided by the three investors.

[0034] The process of using a URL to obtain a protocol document can include the following two implementation methods: First, load a normal web page: Using the loadUrl method of WebView, you can directly load web page content on the Internet.

[0035] Second, load the local HTML file: WebView can also load locally stored HTML files. These files are usually placed in the assets directory of the application and loaded using file: / / / android_asset / as the URL prefix.

[0036] As for protocol documents in other formats (such as protocol documents in PDF format), they can be obtained in the following ways: call a third-party library and use the protocol link as input data when calling the third-party library. The third-party library can load the protocol document according to the protocol link and render the protocol document into the web view container.

[0037] In practice, since the web page protocols that need to be displayed come from different third parties, the styles and encoding formats of the protocol documents may be different.

[0038] S102: Determine the document format of the web page protocol according to the suffix of the protocol link.

[0039] The suffix of the protocol link corresponds to the document format of the protocol document pointed to by the protocol link.

[0040] After the protocol link is determined in step S101, the document format of the protocol document corresponding to the protocol link may be determined according to the suffix of the protocol link.

[0041] For example, a protocol link is https: / / xxxx.com / xxx / 457x.html (it should be noted that the protocol link is a link style provided for example explanation and is not a real link). Then, it can be determined from the suffix of the protocol link that the protocol document corresponding to the protocol link is a document in HTML format.

[0042] S103, determining whether the document format is a first preset format; the first preset format represents a document format that can be parsed into a document object model tree structure.

[0043] Exemplarily, if a document can be encapsulated as a document object model tree, it can be confirmed that the document format of the document is the first preset format. For example, the first preset format can be HTML format, or XML format, etc. It is worth noting that this embodiment only describes the protocol document rendering method using HTML format as an example of the first preset format, and is not a limitation on the first preset format.

[0044] S104: If yes, create a partition label at the highest display position in the current web page view container.

[0045] If the protocol document corresponding to a protocol link is a document in HTML format, a partition label is created in the web view container (webview container) that displays the document.

[0046] The partition tag can be understood as a div tag.

[0047] The div tag is a block-level element and can be seen as a container for rendering document content.

[0048] In some embodiments, to ensure that the protocol document can be rendered end to end in the web view container without re-rendering the document contents, a location parameter may be assigned to the partition tag when the partition tag is created.

[0049] As a feasible implementation, if the document format is HTML format, a partition label is created at the highest display position in the current web page view container. The highest display position can be understood as the starting position in the web page view container where the document can be rendered.

[0050] When rendering the protocol document into the web page view container, the protocol document is rendered starting from the starting position, and after one document is rendered, the starting position is updated.

[0051] As a feasible implementation method, before rendering the first protocol document in the web view container, the highest display position in the current web view container is the highest display position available for document rendering in the web view container. After rendering the first protocol document, the highest display position in the current web view container is changed to the end of the first protocol document, such as the beginning of the next line of the last line of the first protocol document.

[0052] For example, after the previous protocol document A is rendered, a new display line at the end of the document creates a div tag for the protocol document B to be rendered, thereby marking the starting position of the rendering of the protocol document B in the web view container.

[0053] In some embodiments, the div tag may be set at the highest position allowed to be displayed in the web page view container.

[0054] For example, if the protocol document is the first document displayed in the web view container, the div is set to the highest display position of the web view container. If a protocol document has been rendered in the web view container before a protocol document is rendered, a new rendering starts at the end of the latest rendered protocol document.

[0055] S105: Create a first document object model tree with the partition tag as the root node.

[0056] A first DOM tree is created with the div tag created in step S104 as the root node.

[0057] In some embodiments, a new empty shadow DOM tree can be created through shadow dom technology and mounted on a div tag.

[0058] S106, using the protocol link to request the protocol document of the web page protocol, and obtaining the request result of the protocol document.

[0059] The protocol link can be assigned to the protocol document loading command. The processor requests the protocol document of the web page protocol by executing the command. After the command is executed, the processor will obtain the request result of the protocol document.

[0060] The request result of the protocol document may include any of the following two situations: First, the protocol document request is successful, and the request result of the protocol document includes the document content of the protocol document; Second, the protocol document request fails, and the request result of the protocol document does not include the document content of the protocol document. In some embodiments, the request result of the protocol document may include information that the protocol document request failed, such as a flag bit indicating the request failed.

[0061] S107: Update the first document object model tree according to the request result to obtain a target document object model tree.

[0062] According to different request results, the first document object model tree is updated in different ways. Corresponding to the request result, the tree structure of the first document object model tree is updated to obtain the target document object model tree.

[0063] It should be noted that the first document object model tree and the target document object model tree are two forms of the shadow DOM tree mounted on the div node before and after the tree structure is updated.

[0064] In practice, when the style of an HTML document is inconsistent with the style of the page that renders the document, the page style will override the document style and change the layout of the document; When the encoding format of the HTML document is inconsistent with the encoding format of the page rendering the protocol, garbled characters will appear during the document rendering process.

[0065] In general, before rendering the protocol document in HTML format, this application will first create a DOM node with an empty div tag in the web view container as the parent node of the shadow DOM tree. After obtaining the request result, a child node is created based on the parent node. If the protocol document can be requested normally, the protocol content is mounted to the child node through innerHtml. If the protocol document cannot be requested, an iframe tag with src as the protocol link is created, and then the iframe is mounted to the above child node.

[0066] S108, rendering the target document object model tree in the web page view container, rendering the protocol document of the web page protocol into the web page view container, so as to render the protocol documents of different web page protocols into the web page view container in sequence.

[0067] Shadow dom technology can encapsulate protocol documents into an independent DOM tree structure. By rendering the target document object model tree with the tree structure corresponding to the protocol document into the web view container, the rendering of the HTML formatted protocol document in the web view container is realized. When rendering the HTML formatted protocol document, it is isolated from the web view container to avoid garbled characters during the rendering process.

[0068] This application renders different protocol documents in sequence, end to end, into a web view container.

[0069] In summary, after obtaining the protocol link of the web page protocol to be displayed, the protocol display method proposed in the embodiment of the present application first determines the document format of the web page protocol according to the suffix of the protocol link. If the document format of the web page protocol is the first preset format, first create a partition tag in the web page view container, and use the partition tag as the root node to create a first document object model tree. Then, use the protocol link to request the protocol document of the web page protocol to obtain the request result of the protocol document. According to the request result, update the first document object model tree to obtain the target document object model tree. By rendering the target document object model tree in the web page view container, the protocol document of the first preset format is rendered into the web page view container. In this way, the protocol documents of different web pages can be rendered into the web page view container in sequence. In this way, when rendering documents in the first preset format including the HTML format, there is no need to perform format conversion. By establishing a document object model tree that can isolate the style for the document in the first preset format, independent rendering of the document in the first preset format is achieved in the web view container, thereby avoiding garbled characters due to style mismatch or encoding mismatch during the rendering process, thereby avoiding the process of converting the HTML format protocol document to the PDF format, and further avoiding the high error risk brought by the format conversion process. The HTML documents can be rendered into the web view container quickly and accurately in sequence, thereby improving the efficiency of the head-to-tail splicing display of the web protocol.

[0070] As a feasible implementation method, Figure 2 As shown, the above step S107 of "updating the first document object model tree according to the request result to obtain the target document object model tree" may include the following steps: S201, determining whether the request result includes information of successful request; In some embodiments, the request success information may be represented by a request success flag, or by directly determining whether the request result includes the request success information by determining whether the request result includes a protocol document.

[0071] If the request result includes a protocol document, it is considered that the request result includes information that the request is successful; if the request result does not include a protocol document, it is considered that the request result does not include information that the request is successful.

[0072] S202: If the request result includes information indicating that the request is successful, encapsulate the protocol document included in the request result into a first target tree structure.

[0073] If the request result includes information indicating a successful request, it can be considered that the request has been successfully made to the protocol document, which will be included in the request result.

[0074] The present application encapsulates the protocol document (such as a document in HTML format) included in the request result into a DOM tree structure, which is recorded as the first target tree structure in the embodiment of the present application.

[0075] S203: Update the tree structure of the first DOM tree to a first target tree structure; and use the updated first DOM tree as a target DOM tree.

[0076] In some embodiments, the original tree structure of the first document object model tree may be replaced by the first target tree structure.

[0077] In the above embodiment, the first document object model tree is established as an empty DOM tree. Then in step S203, the first target tree structure can be used as the tree structure of the first document object model tree.

[0078] The first DOM tree after the tree structure is replaced is used as the target DOM tree, so as to distinguish it from the first DOM tree before the tree structure is replaced.

[0079] After requesting the protocol document, this embodiment encapsulates the protocol document into a DOM tree structure, mounts it into the first document object model tree, and obtains the target document object model tree used for document rendering. In this way, the document is encapsulated into an independent rendering space that is style-isolated from the web page view container, avoiding garbled characters during the rendering process.

[0080] As another possible implementation, Figure 3 As shown, in step S107, "updating the first document object model tree according to the request result to obtain the target document object model tree" may include the following steps: S301, determining whether the request result includes information of successful request; S302, if the request result includes information indicating that the request is successful, encapsulate the protocol document included in the request result into a first target tree structure; The specific implementation of steps S301-S302 is the same as the specific implementation of S201-S202 in the above embodiment, and will not be repeated here.

[0081] S303: Update the tree structure of the first document object model tree to a first target tree structure.

[0082] In this step, the tree structure of the first document object model tree is updated to the first target tree structure, which is the same as updating the tree structure of the first document object model tree to the first target tree structure in step S203 of the above embodiment.

[0083] The embodiments of this application are Figure 2After the tree structure of the first document object model tree is updated in the illustrated embodiment, the following steps are further added to solve the problem that the document converted from the second preset format (editable document format, such as WORD format) to the first preset format (such as HTML format) will be directly rendered after being encapsulated into the first target tree structure, and garbled characters will appear during the rendering process. For ease of understanding, the following will explain the garbled characters that will appear during the rendering process of "converting the WORD format to the HTML format document": Since the document converted from WORD format to HTML format is in the xmlns namespace, if the HTML content in the Shadow DOM tree contains XML namespaces, then these namespaces will become part of the element and affect the selection and operation of the element. For example, an element with a namespace Cannot be directly passed through ordinary CSS selectors to be selected, because the selector needs to include the namespace prefix.

[0084] Therefore, although Shadow DOM provides isolation in style, it does not automatically handle XML namespace issues. If the HTML content in the Shadow DOM tree contains namespaces, and these namespaces do not match the main page (ie, the web view container) or the main page does not use namespaces at all, then elements may not be correctly identified, which may cause layout problems or garbled characters.

[0085] In view of this situation, the embodiment of the present application adds the following processing steps: S304, parsing the header metadata information of the protocol document to determine whether the protocol document is obtained after format conversion of a document in a second preset format.

[0086] For example, by identifying the meta tag in the requested protocol document, if meta[content="Word.Document"] is present, it is considered that the protocol document is obtained after format conversion from a WORD document.

[0087] S305: If the protocol document is obtained by format conversion of a document in the second preset format, pre-rendering the updated document object model tree in the web page view container to pre-render the protocol document into the web page view container.

[0088] Exemplarily, if a certain protocol document is obtained after format conversion of a WORD document, the updated first document object model tree is pre-rendered in the web view container, that is, the protocol document is rendered into the web view container.

[0089] S306, obtaining the display height of the protocol document in the web page view container, and clearing the pre-rendered display content.

[0090] After pre-rendering, garbled characters will appear in the rendered display content, but the current document display height can be regarded as the display height when the protocol document is fully displayed in the web view container.

[0091] Therefore, the display height of the document may be obtained through the updated scrollHeight of the first document object model tree, and after the display height is obtained, the pre-rendered display content may be cleared.

[0092] S307, creating an inline frame tag, assigning the display height to the height attribute of the inline frame tag, and assigning the protocol link to the source attribute of the inline frame tag; S308, encapsulating the assigned inline frame tag into a second target tree structure; S309: Replace the first target tree structure of the first DOM tree with the second target tree structure; and use the first DOM tree after the tree structure is replaced as the target DOM tree.

[0093] For example, after determining the display height of the protocol document in the web page view container, create a new iframe tag (i.e., the above-mentioned inline frame tag), assign the display height to the Height attribute of the iframe tag (i.e., the above-mentioned height attribute), and assign the protocol link of the protocol document to the src attribute of the iframe tag (i.e., the above-mentioned source attribute).

[0094] The assigned iframe tag is encapsulated as a document object model tree structure as the second target tree structure. The first target tree structure in the first document object model tree is replaced with the second target tree structure to obtain the first document object model tree with the second target tree structure, that is, the first document object model tree after the tree structure is replaced in this embodiment. The first document object model tree after the tree structure is replaced is used as the target document object model tree.

[0095] In this way, for the protocol document converted from WORD format to HTML format, the iframe technology is used to embed the HTML protocol to solve the problem of garbled characters in the rendering process and ensure that the display height provided for the protocol document can enable the protocol document to be fully displayed in the web page view.

[0096] It is worth noting that this embodiment only takes the HTML format as an example of the first preset format and the WORD format as an example of the second preset format, and does not limit the first preset format and the second preset format.

[0097] In some embodiments, the protocol document converted from WORD format to HTML format may also be rendered in the following manner: standardize the HTML protocol format, generate a new HTML-formatted protocol link for the protocol document, and ensure that the xmlns namespace does not appear.

[0098] Based on the above embodiment, after parsing the header metadata information of the protocol document in the above step S304 to determine whether the protocol document is obtained after format conversion of the document in the second preset format, the method further includes: If the protocol document is not obtained by format conversion of a document in the second preset format, the updated first document object model tree is used as the target document object model tree.

[0099] Exemplarily, if a protocol document in HTML format is not obtained by format conversion of a document in WORD format, there is no need to perform the above steps S305-S309, and the updated first document object model tree can be directly used as the target document object model tree to participate in the document rendering process of the above step S108.

[0100] In practice, some protocol links are provided by external parties, and there will be cross-domain issues when requesting protocol content.

[0101] To solve this problem, in the embodiment of the present application, after "determining whether the request result includes information on successful request" in the above step S201 / S301, the method further includes the following steps: If the request result does not include information that the request is successful, an inline frame tag is created, and the protocol link is assigned to the source attribute of the inline frame tag, and the preset display height is assigned to the height attribute of the inline frame tag; the assigned inline frame tag is encapsulated into a third target tree structure; the tree structure of the first document object model tree is updated to the third target tree structure, and the updated first document object model tree is used as the target document object model tree.

[0102] For example, if the obtained request result does not include the protocol document, or there is no valid request success flag, the protocol document request is considered to have failed, and a new iframe tag is created, and the protocol link is assigned to the src attribute of the iframe tag. The assigned iframe tag is added to the first document object model tree as a new tree structure of the first document object model tree, and the first document object model tree embedded with the inline frame tag is used as the target document object model tree.

[0103] In this embodiment, for a protocol document that needs to be obtained across domains, when the protocol content cannot be obtained, the rendering of the cross-domain document is achieved by mounting the protocol link into the established DOM tree.

[0104] Based on the above embodiment, after "determining whether the document format is the first preset format" in the above step S103, the method further includes: If not, call the third-party parsing library corresponding to the document format, and use the highest display position and the protocol link as input data when calling the third-party parsing library, so that the third-party parsing library loads the protocol document according to the protocol link and starts rendering the protocol document from the highest display position.

[0105] For example, for a certain protocol link, it is determined from the suffix of the protocol link that the protocol document of the protocol link is a document in PDF format, so the PDF.js library is called, and the protocol link and the current highest display position of the web view container are passed to the PDF.js library, so that the PDF.js library renders the PDF document into the web view container.

[0106] In one example, for processing formats other than HTML, the document can be rendered by calling a third-party parsing library corresponding to the document format to avoid problems such as garbled characters during the rendering process.

[0107] Based on the above embodiments, Figure 4 As shown, the above step S101 of "obtaining protocol links of multiple web page protocols to be displayed" may include the following steps: S401, after detecting that a marked page is displayed on the front end, obtaining a user identifier associated with the marked page; the marked page represents a front end page for triggering the display of a web page protocol.

[0108] S402, filtering unread protocols corresponding to the user identifier from all web page protocols that need to be displayed to the user; S403, obtaining protocol links of unread protocols as protocol links of multiple web page protocols that need to be displayed.

[0109] Exemplarily, the marking page can be a user registration page or a service activation page, etc. After the user enters the marking page, the background configuration is queried for all the major categories of agreements displayed to users. The background returns the identifier of the configured major category of agreements after the query. The identifier of the major category of agreements is used to query the content of the agreement displayed to the current user. The background queries the specific agreement under the major category identifier of the agreement, and filters the agreements that the user has viewed and submitted for consent. The front end obtains the agreement name and agreement link for display.

[0110] In this embodiment, after the user enters the marked page, the client can automatically obtain the protocol links of the web page protocols that need to be displayed to the user, so as to quickly and accurately display these protocol links of the web page protocols to the user in a head-to-tail splicing form to facilitate user reading.

[0111] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0112] Figure 5 is a block diagram of a protocol display device according to an exemplary embodiment of the present application. Figure 5 As shown, the device 500 includes: a first acquisition module 501, a determination module 502, a judgment module 503, a first creation module 504, a second creation module 505, a second acquisition module 506, an update module 507 and a rendering module 508.

[0113] A first acquisition module 501 is used to acquire protocol links of multiple web page protocols that need to be displayed; A determination module 502, configured to determine the document format of the webpage protocol according to the suffix of the protocol link; The judgment module 503 is used to judge whether the document format is a first preset format; the first preset format represents a document format that can be parsed into a document object model tree structure; A first creation module 504 is used to create a partition label at the highest display position in the current web page view container if yes; The second creation module 505 is used to create a first document object model tree with the partition tag as the root node; The second acquisition module 506 is used to request the protocol document of the webpage protocol by using the protocol link and obtain the request result of the protocol document; An updating module 507, configured to update the first document object model tree according to the request result to obtain a target document object model tree; The rendering module 508 is used to render the protocol documents of the web protocol into the web view container by rendering the target document object model tree in the web view container, so as to render the protocol documents of different web protocols into the web view container in sequence.

[0114] In the embodiment of the present application, the update module is used to: Determine whether the request result includes information about successful request; If the request result includes information indicating that the request is successful, encapsulating the protocol document included in the request result into a first target tree structure; The tree structure of the first document object model tree is updated to a first target tree structure; and the updated first document object model tree is used as a target document object model tree.

[0115] In the embodiment of the present application, the update module is used to: Determine whether the request result includes information about successful request; If the request result includes information indicating that the request is successful, encapsulating the protocol document included in the request result into a first target tree structure; Updating the tree structure of the first document object model tree to a first target tree structure; Parsing the header metadata information of the protocol document to determine whether the protocol document is obtained after format conversion of a document in a second preset format; If the protocol document is obtained by format conversion of a document in the second preset format, pre-rendering the updated first document object model tree in the web view container to pre-render the protocol document into the web view container; Get the display height of the protocol document in the web view container and clear the pre-rendered display content; Create an inline frame tag, assign the display height to the height attribute of the inline frame tag, and assign the protocol link to the source attribute of the inline frame tag; Encapsulate the assigned inline frame tag into a second target tree structure; The first target tree structure of the first document object model tree is replaced with the second target tree structure; and the first document object model tree after the tree structure is replaced is used as the target document object model tree.

[0116] In the embodiment of the present application, the update module, after parsing the header metadata information of the protocol document and determining whether the protocol document is obtained after format conversion of the second preset format document, is further used to: If the protocol document is not obtained by format conversion of a document in the second preset format, the updated first document object model tree is used as the target document object model tree.

[0117] In the embodiment of the present application, the update module is also used to: If the request result does not include the information of successful request, a new inline frame tag is created, and the protocol link is assigned to the source attribute of the inline frame tag; Encapsulate the assigned inline frame tag into a third target tree structure; The tree structure of the first document object model tree is updated to a third target tree structure; and the updated first document object model tree is used as the target document object model tree. In the embodiment of the present application, after determining whether the document format is the first preset format, the device is also used to: If not, call the third-party parsing library corresponding to the document format to render the protocol document into the web view container.

[0118] In the embodiment of the present application, the acquisition module is used to: After detecting that the marked page is displayed on the front end, obtaining a user identifier associated with the marked page; the marked page represents a front end page used to trigger the display of the web page protocol; Filter out the unread agreements corresponding to the user ID from all web page agreements that need to be displayed to the user; Get the agreement link for unread agreements.

[0119] In summary, after obtaining the protocol link of the web protocol to be displayed, the device first determines the document format of the web protocol according to the suffix of the protocol link. If the document format of the web protocol is the first preset format, a partition tag is first created in the web view container, and the first document object model tree is created with the partition tag as the root node. Then, the protocol link is used to request the protocol document of the web protocol to obtain the request result of the protocol document. According to the request result, the first document object model tree is updated to obtain the target document object model tree. The document of the first preset format is rendered into the web view container by rendering the target document object model tree in the web view container. In this way, the protocol documents of different web protocols can be rendered into the web view container in sequence. In this way, when rendering the document of the first preset format including the HTML format, there is no need to perform format conversion. By establishing a document object model tree that can isolate the style for the document of the first preset format, the independent rendering of the document of the first preset format is realized in the web view container, thereby avoiding garbled characters due to style mismatch or encoding mismatch during the rendering process. The HTML document can be quickly rendered into the web view container, improving the efficiency of the head-to-tail splicing display of the web protocol.

[0120] To implement the above-mentioned embodiment, the embodiment of the present application also proposes an electronic device 600, including a memory 601, a processor 602, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the protocol display method in the above-mentioned embodiment are implemented.

[0121] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0122] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.

[0123] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A protocol display method, characterized in that: The method comprises: Obtain protocol links of multiple web page protocols that need to be displayed; Determining the document format of the web page protocol according to the suffix of the protocol link; Determining whether the document format is a first preset format; the first preset format represents a document format that can be parsed into a document object model tree structure; If yes, create a partition label at the highest display position in the current web page view container; Creating a first document object model tree with the partition tag as a root node; Utilizing the protocol link, requesting the protocol document of the webpage protocol, and obtaining a request result of the protocol document; According to the request result, updating the first document object model tree to obtain a target document object model tree; By rendering the target document object model tree in the web page view container, the protocol document of the web page protocol is rendered into the web page view container, so that the protocol documents of different web page protocols are sequentially rendered into the web page view container in a head-to-tail manner.

2. The method according to claim 1, characterized in that The updating the first document object model tree according to the request result to obtain a target document object model tree includes: Determine whether the request result includes information that the request is successful; If the request result includes information indicating that the request is successful, encapsulating the protocol document included in the request result into a first target tree structure; The tree structure of the first document object model tree is updated to the first target tree structure; and the updated first document object model tree is used as the target document object model tree.

3. The method according to claim 1, characterized in that The updating the first document object model tree according to the request result to obtain a target document object model tree includes: Determine whether the request result includes information that the request is successful; If the request result includes information indicating that the request is successful, encapsulating the protocol document included in the request result into a first target tree structure; Updating the tree structure of the first document object model tree to the first target tree structure; Parsing the header metadata information of the protocol document to determine whether the protocol document is obtained after format conversion of a document in a second preset format; the second preset format represents the format of an editable document; If the protocol document is obtained by format conversion of a document in a second preset format, pre-rendering the updated first document object model tree in the web page view container to pre-render the protocol document into the web page view container; Obtaining the display height of the protocol document in the web page view container, and clearing the pre-rendered display content; Creating an inline frame tag, assigning the display height to a height attribute of the inline frame tag, and assigning the protocol link to a source attribute of the inline frame tag; Encapsulating the assigned inline frame tag into a second target tree structure; The first target tree structure of the first document object model tree is replaced with the second target tree structure; and the first document object model tree after the tree structure is replaced is used as the target document object model tree.

4. The method according to claim 3, characterized in that After parsing the header metadata information of the protocol document and determining whether the protocol document is obtained after format conversion of a document in a second preset format, the method further includes: If the protocol document is not obtained by converting the format of a document in the second preset format, the updated first document object model tree is used as the target document object model tree.

5. The method according to claim 2 or 3, characterized in that: After determining whether the request result includes information of a successful request, the method further includes: If the request result does not include information that the request is successful, an inline frame tag is created, and the protocol link is assigned to a source attribute of the inline frame tag, and a preset display height is assigned to a height attribute of the inline frame tag; Encapsulating the assigned inline frame tag into a third target tree structure; The tree structure of the first document object model tree is updated to the third target tree structure; and the updated first document object model tree is used as the target document object model tree.

6. The method according to claim 1, characterized in that After determining whether the document format is the first preset format, the method further includes: If not, call the third-party parsing library corresponding to the document format, and use the highest display position and the protocol link as input data when calling the third-party parsing library, so that the third-party parsing library loads the protocol document according to the protocol link and starts rendering the protocol document from the highest display position.

7. The method according to claim 1, characterized in that The step of obtaining protocol links of multiple web page protocols to be displayed includes: When it is detected that the marked page is displayed on the front end, a user identifier associated with the marked page is obtained; the marked page represents the front end page used to trigger the display of the web page protocol; Filtering unread protocols corresponding to the user identifier from all web page protocols that need to be displayed to the user; The protocol link of the unread protocol is obtained as the protocol link of the multiple web page protocols that need to be displayed.

8. A protocol display device, characterized in that: The device comprises: A first acquisition module, used for acquiring protocol links of multiple web page protocols to be displayed; A determination module, used to determine the document format of the web page protocol according to the suffix of the protocol link; A determination module, configured to determine whether the document format is a first preset format; the first preset format represents a document format that can be parsed into a document object model tree structure; A first creation module is used to create a partition label at the highest display position in the current web page view container if yes; A second creation module, used to create a first document object model tree with the partition tag as a root node; A second acquisition module, used to request a protocol document of the webpage protocol using the protocol link, and obtain a request result of the protocol document; An updating module, used for updating the first document object model tree according to the request result to obtain a target document object model tree; A rendering module is used to render the target document object model tree in the web page view container to render the protocol document of the web page protocol into the web page view container, so as to render the protocol documents of different web page protocols into the web page view container in sequence.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the protocol display method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the protocol display method as described in any one of claims 1 to 7 are implemented.