Web page display method, device, electronic device and readable storage medium

By creating target element classes in browsers that comply with W3C standards and associating them with web page elements, the problem of browsers not supporting component file addition event behavior is solved and the web page display effect is improved.

CN118897709BActive Publication Date: 2025-01-21龙芯中科(合肥)技术有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411398329.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-08
Publication Date
2025-01-21
Estimated Expiration
2044-10-08

AI Technical Summary

Technical Problem

Browsers that comply with W3C standards do not support adding event behavior to web page elements through component files, resulting in poor web page display.

Method used

In browsers that comply with W3C standards, event behavior tag information is obtained by obtaining the event behavior tag information of web page elements, creating a target element class, and associating it with the element to be processed to realize the encapsulation and addition of event behavior.

Benefits of technology

It avoids the problem that browsers do not support adding event behaviors to component files, improves the display effect of web pages, and enables the event behaviors of web page elements to effectively take effect in W3C standard browsers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118897709B_ABST
    Figure CN118897709B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention provides a web page display method, device, electronic device and readable storage medium, the method comprising: in response to a web page display request, based on the web page to be displayed corresponding to the web page display request, obtaining a web page element with event behavior added in the web page to be displayed as an element to be processed; obtaining a web page declaration file corresponding to the element to be processed, and obtaining tag information of the event behavior added to the element to be processed based on the web page declaration file; creating a target element class, and setting tag information of the target element class based on the tag information; associating the target element class with the element to be processed in the web page to be displayed, and displaying the web page to be displayed. The method avoids the invalidity problem caused by the browser that complies with the W3C standard not supporting the addition of event behavior to the web page element through the component file, and improves the web page display effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of web pages, and in particular relates to a web page display method, device, electronic equipment and readable storage medium. Background Art

[0002] With the development of web technology, many websites or systems can create web pages, and users can browse different web pages through browsers. Currently, most web page development is achieved through Hypertext Markup Language (HTML). On this basis, Microsoft's web browser (Internet Explorer, IE) version 5.0 introduced a component mechanism, which can write reusable components and generate component files for web pages.

[0003] In the prior art, event behaviors can be attached to web page elements through component files, but web browsers that comply with the World Wide Web Consortium (W3C) standards (e.g., Google Chrome) do not support attaching event behaviors to web page elements through component files, resulting in that when web pages containing component files are loaded in these browsers, the behaviors attached to the web page elements are invalid, resulting in poor web page display effects. Summary of the invention

[0004] The present invention provides a web page display method, device, electronic device and readable storage medium to solve the problem of poor web page display effect.

[0005] In order to solve the above-mentioned technical problems, the present invention is achieved as follows:

[0006] In a first aspect, the present invention provides a web page display method, characterized in that it is applied to a browser that complies with the W3C standard, comprising:

[0007] In response to a web page display request, based on a web page to be displayed corresponding to the web page display request, obtaining a web page element to which an event behavior is added in the web page to be displayed as an element to be processed;

[0008] Obtaining a webpage declaration file corresponding to the element to be processed, and obtaining label information of the event behavior added to the element to be processed based on the webpage declaration file; the webpage declaration file is a file incompatible with the W3C standard, and the webpage declaration file is used to define the event behavior;

[0009] Creating a target element class, and setting tag information of the target element class based on the tag information;

[0010] The target element class is associated with the element to be processed in the web page to be displayed, and the web page to be displayed is displayed.

[0011] In a second aspect, the present invention provides a web page display device, characterized in that it is applied to a browser that complies with the W3C standard, and the device comprises:

[0012] A first acquisition module, in response to a web page display request, acquires a web page element with an event behavior added in the web page to be displayed as an element to be processed based on the web page to be displayed corresponding to the web page display request;

[0013] A second acquisition module is used for a webpage declaration file corresponding to the element to be processed, and acquires label information of the event behavior added to the element to be processed based on the webpage declaration file; the webpage declaration file is a file incompatible with the W3C standard, and the webpage declaration file is used to define the event behavior;

[0014] A creation module, used for creating a target element class and setting tag information of the target element class based on the tag information;

[0015] The association module is used to associate the target element class with the element to be processed in the web page to be displayed, and display the web page to be displayed.

[0016] In a third aspect, the present invention provides an electronic device, comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned web page display method when executing the program.

[0017] In a fourth aspect, the present invention provides a readable storage medium, when instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the above-mentioned web page display method.

[0018] The web page display method provided by the embodiment of the present invention responds to a web page display request, based on the web page to be displayed corresponding to the web page display request, obtains a web page element with event behavior added to the web page to be displayed as an element to be processed; obtains a web page declaration file corresponding to the element to be processed, and obtains tag information of the event behavior added to the element to be processed based on the web page declaration file; creates a target element class, and sets tag information of the target element class based on the tag information; associates the target element class with the element to be processed in the web page to be displayed, and displays the web page to be displayed. By creating a target element class for the element to be processed, and setting tag information of the target element class based on the web page declaration file corresponding to the element to be processed, the event behavior added to the element to be processed in the web page declaration file can be encapsulated, and the target element class is the code obtained by encapsulation. In this way, by associating the element to be processed with the target element class in the web page to be displayed, the event behavior can be directly added to the element to be processed in the web page, and the event behavior is no longer added through the component file, thereby avoiding the invalid problem caused by the browser that complies with the W3C standard not supporting the addition of event behavior to the web page element through the component file, and improving the web page display effect. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0020] Figure 1 is a flowchart of a method for displaying a web page provided by an embodiment of the present invention;

[0021] Figure 2 is a structural diagram of a web page display device provided by an embodiment of the present invention;

[0022] Figure 3 It is a structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0023] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0024] Figure 1is a flowchart of a method for displaying a web page provided by an embodiment of the present invention. The method can be applied to a browser that complies with the W3C standard, such as Figure 1 As shown, the method may include the following steps:

[0025] Step 101 : In response to a web page display request, based on a web page to be displayed corresponding to the web page display request, a web page element with an event behavior added thereto in the web page to be displayed is obtained as an element to be processed.

[0026] Step 102: Obtain a webpage declaration file corresponding to the element to be processed, and obtain tag information of the event behavior added to the element to be processed based on the webpage declaration file.

[0027] Step 103: Create a target element class, and set tag information of the target element class based on the tag information.

[0028] Step 104: Associating the target element class with the element to be processed in the web page to be displayed, and displaying the web page to be displayed.

[0029] With respect to the above steps 101 to 104, the embodiment of the present invention can be applied to any web browser that complies with the World Wide Web Consortium (W3C) standard, such as Chrome, Loongson browser, etc., and the embodiment of the present invention does not limit this. The above web page display request can be sent by the user through the actual web page display demand, which can carry the web page address, that is, the Uniform Resource Locator (URL) address. On this basis, the web page to be displayed can be obtained by accessing the URL address contained in the web page display request.

[0030] Furthermore, when the browser accesses the URL address of the web page to be displayed, it can obtain the web page design file corresponding to the web page to be displayed. The web page design file refers to a World Wide Web (web) structure standard file, which contains codes written in a lightweight scripting language (JavaScript, JS), which is used to define the page structure and page content of the web page. Different contents in the page correspond to different web page elements. On this basis, the embodiment of the present invention can obtain the web page element with event behavior added in the web page to be displayed as the element to be processed through the web page design file.

[0031] The above-mentioned event behavior includes events and behaviors. Events refer to interactive events with web page elements, and behaviors refer to operations to be performed after the above-mentioned events are triggered on the web page elements. Exemplarily, the above-mentioned events may be mouse hover events, click events, etc., and the above-mentioned behaviors may be jumping to a specified page or executing a specified instruction. The above-mentioned events and behaviors may be set by the designer himself during the web page design stage, and the embodiments of the present invention do not limit this.

[0032] Furthermore, in a web design file, event behaviors are usually added to web elements by setting a namespace. Namespace refers to a declarative area, which is equivalent to an isolated environment and can be used to divide event behaviors added by different web elements. On this basis, the embodiment of the present invention can traverse each web element in the web design file. If there is a namespace declaration before the name of a web element, it can be determined that the web element has event behaviors added, and the web element can be used as an element to be processed.

[0033] The web page declaration file is a file used to define event behaviors, i.e., a component file, which is incompatible with the W3C standard. Therefore, a browser that complies with the W3C standard cannot add event behaviors to web page elements through the component file. The component file can be a Hypertext Markup Language Component (HTML Components) file or an Extensible Binding Language (XML Binding Language, XBL) file, which is not limited in the embodiment of the present invention.

[0034] Specifically, XBL allows developers to bind specific behaviors and event handlers to web page elements (XUL elements) to create interactive user interface components. XBL files contain a set of binding lists, each of which describes the behavior pattern of a XUL component, including content, properties, methods, events, and styles. Correspondingly, HTC can also allow developers to bind specific event behaviors to web page elements. HTC files contain multiple tags, including methods, properties, events, and behaviors.

[0035] Specifically, a component file can define and declare one or more event behaviors. Accordingly, the above tag information refers to the specific content of the defined event behavior. A web page can apply multiple event behaviors. Accordingly, a web page can correspond to one or more component files. Furthermore, one or more event behaviors can be added to a web page element. On this basis, a to-be-processed element can correspond to one or more component files.

[0036] Furthermore, after receiving a web page display request, the embodiment of the present invention can simultaneously obtain the web page design file and the web page declaration file through the URL address contained in the web page display request. Specifically, the file acquisition request can be sent to the URL address through an interface function set (XMLHttpRequest) to obtain the web page design file and all web page declaration files used by the web page to be displayed. Further, in the case where the web page to be displayed contains multiple elements to be processed, the web page display method provided by the embodiment of the present invention can be executed separately for each element to be processed. Furthermore, the namespace corresponding to the element to be processed can contain the file identifier of the corresponding component file, so that the web page declaration file corresponding to the element to be processed can be obtained from all the obtained web page declaration files through the file identifier.

[0037] Furthermore, after obtaining the web page declaration file corresponding to the element to be processed, the embodiment of the present invention can obtain the content contained therein to obtain the label information of the event behavior added by the element to be processed. Specifically, after obtaining the web page declaration file, the content in the web page declaration file can be converted into a document element (documentElement) through the HTML parsing interface (DOMParser). The converted content is usually in the form of a document node (Document Object Model, DOM). Different nodes correspond to different label information. Therefore, the obtained DOM nodes can be traversed to obtain the attribute values ​​corresponding to each DOM node in turn, and then the above-mentioned label information can be obtained.

[0038] Optionally, the tag information includes a method tag, an attribute tag, an event tag, and a behavior tag. The operation of acquiring the tag information of the event behavior added to the element to be processed based on the webpage declaration file may specifically include:

[0039] S1021, converting the content contained in the webpage declaration file into a document node;

[0040] S1022, traversing the converted document nodes, and acquiring method nodes, attribute nodes, event nodes, and behavior nodes in sequence based on the node identifier of each document node;

[0041] S1023. Based on the method nodes, attribute nodes, event nodes, and behavior nodes, respectively obtain method tags, attribute tags, event tags, and behavior tags.

[0042] Among them, the above-mentioned method tag refers to the attribute value of the method node, which is used to represent the method defined in the component file and applied to the web page to be displayed. The above-mentioned attribute tag refers to the attribute value of the attribute node, which is used to represent the attribute defined in the component file and applied to the web page to be displayed. The above-mentioned event tag refers to the attribute value of the event node, which is used to represent the event defined in the component file and applied to the web page to be displayed. The above-mentioned behavior tag refers to the attribute value of the behavior node, which is used to represent the method bound to the event defined in the component file. When the to-be-processed element in the web page to be displayed triggers the bound event, the behavior represented by the behavior tag is executed, which is usually in the form of a function.

[0043] Among them, the above conversion operation can be implemented through the DOMParser interface. The above node identifier refers to the tagName of the DOM node. Further, the above method node, attribute node, event node and behavior node can be obtained in sequence through the node identifier. Specifically, the node identifier of each DOM node can be used to compare with the reference node identifier corresponding to the method node, attribute node, event node and behavior node respectively. When it is consistent with a reference node identifier, it can be confirmed that the node is the node corresponding to the reference node identifier. Exemplarily, taking the HTC file as an example, the reference node identifier corresponding to the method node is usually PUBLIC:METHOD, and correspondingly, the reference node identifier corresponding to the attribute node is usually PUBLIC:PROPERTY, and correspondingly, the reference node identifier corresponding to the event node is usually PUBLIC:EVENT, and correspondingly, the reference node identifier corresponding to the behavior node is usually PUBLIC:ATTACH.

[0044] Furthermore, after obtaining the method nodes, attribute nodes, event nodes, and behavior nodes, the attribute values ​​of each node can be obtained in turn through the attribute acquisition interface (getAttribute), and the attribute values ​​of the method nodes can be determined as method tags, the attribute values ​​of the attribute nodes can be determined as attribute tags, the attribute values ​​of the event nodes can be determined as event tags, and the attribute values ​​of the behavior nodes can be determined as behavior tags.

[0045] The embodiment of the present invention can implement parsing of the component file through the above method to obtain the label information of the event behavior added by the component file to the element to be processed.

[0046] After obtaining the tag information of the event behavior added to the element to be processed based on the webpage declaration file, the embodiment of the present invention can encapsulate the tag information using compatible code. Specifically, a target element class can be created, and the tag information of the target element class can be set based on the tag information. Specifically, the above creation operation can be implemented by JS language to make the target element class suitable for browsers such as Chrome, FireFox, Edge, etc.

[0047] Specifically, the target element class can be created by creating an interface (create), on which the target element class is not an element class provided by the component, but a custom element class. Further, the embodiment of the present invention can set label information for the target element class, specifically, the label information can be set for the target element class based on the acquired label information of the event behavior added to the element to be processed.

[0048] Optionally, the operation of setting the tag information of the target element class based on the tag information in the embodiment of the present invention may specifically include:

[0049] Tag information consistent with the tag information is set in the target element class.

[0050] Specifically, the tag information consistent with the above tag information can be set in the target element class. Specifically, the above attribute tag usually contains an attribute node ( <public:property>Node), you can create "getter" and "setter" methods for the corresponding attributes in the target element class, where the attribute name created in the target element class is the name attribute value, the getter method is the get attribute value, and the setter method is the put attribute value.

[0051] Furthermore, the above method tags usually contain method nodes ( <public:method>Node), you can create a corresponding method in the target element class and set its attribute value to the function pointed to by the name attribute value. Accordingly, the above event tag usually contains the event node ( <public:event>Node), you can create a corresponding event in the target element class and set its attribute value to the function pointed to by the name attribute value.

[0052] Accordingly, the above behavior tags usually contain behavior nodes ( <public:attach>Node), it is also necessary to determine whether the event is a built-in event based on the event attribute value. If it is not a built-in event, it is necessary to create a corresponding event for the custom element, and then use the addEventListener method to bind the event to the custom element. The event callback function is the method pointed to by the onevent attribute value.

[0053] Optionally, when the component file is an XBL file, the tag information may also include a constructor node ( <constructor>) and destructor nodes ( <destructor>), which are used to map to the connectedCallback and disconnectedCallback lifecycle callback functions of the custom element respectively.

[0054] In an embodiment of the present invention, creating a target element class and setting the tag information of the target element class through the above steps is equivalent to repackaging the code in the component file, avoiding the problem of invalid event behavior addition caused by the inability of the web page to parse the component file. The web page can identify the encapsulated target element class, so that the encapsulated target element class can be easily associated with the element to be processed in the web page to be displayed.

[0055] Furthermore, after obtaining the target element class, the target element class can be associated with the element to be processed in the web page to be displayed, and the web page to be displayed can be displayed. Specifically, the above association method can be implemented through an association interface, or the target element class can be used to register the target element, and the target element can be used to replace the element to be processed. Specifically, different association methods can be used according to the category of the element to be processed.

[0056] In summary, in the embodiment of the present invention, in response to a web page display request, based on the web page to be displayed corresponding to the web page display request, a web page element with event behavior added to the web page to be displayed is obtained as an element to be processed; a web page declaration file corresponding to the element to be processed is obtained, and based on the web page declaration file, label information of the event behavior added to the element to be processed is obtained; a target element class is created, and label information of the target element class is set based on the label information; the target element class is associated with the element to be processed in the web page to be displayed, and the web page to be displayed is displayed. By creating a target element class for the element to be processed, and setting label information of the target element class based on the web page declaration file corresponding to the element to be processed, the event behavior added to the element to be processed in the web page declaration file can be encapsulated, and the target element class is the code obtained by encapsulation. In this way, by associating the element to be processed with the target element class in the web page to be displayed, event behavior can be directly added to the element to be processed in the web page, and the event behavior is no longer added through component files, which avoids the invalid problem caused by the browser that complies with the W3C standard not supporting the addition of event behavior to the web page element through component files, and improves the web page display effect.

[0057] Optionally, after the operation of obtaining the web page element to which the event behavior is added in the web page to be displayed as the element to be processed, the embodiment of the present invention may specifically include:

[0058] S21. Obtain identification information of the element to be processed.

[0059] In the case where the identification information belongs to the target identification set, the operation of associating the target element class with the element to be processed in the web page to be displayed may specifically include:

[0060] S22. In the web page to be displayed, the target element class is set as the event behavior of the element to be processed through an association interface to associate the target element class with the element to be processed; the target identification set includes element identifications of elements identifiable by the web page.

[0061] The identification information refers to the tagName of the element to be processed, and the target identification set includes element identifications of identifiable elements on the web page. The identifiable elements on the web page refer to ordinary HTML elements or XUL elements, which are supported by the HTML5 standard and can be recognized and displayed by the browser. For example, the element identifications usually included in the target identification set are SPAN, TABLE, H2, etc.

[0062] Specifically, when the identification information of the element to be processed belongs to the above target identification set, it indicates that the element to be processed can be directly identified and displayed. At this time, the target element class can be directly set as the event behavior of the element to be processed through the association interface in the web page to be displayed, so as to realize the association between the target element class and the element to be processed. Among them, the above association interface refers to the event listening interface (addEventListener), which can listen to the events occurring on the element to be processed, and execute the behavior in the target element class when the events in the target element class are listened.

[0063] In an embodiment of the present invention, when the identification information of the element to be processed belongs to the element identification of an element identifiable by the web page, the target element class can be directly set as the event behavior of the element to be processed through the association interface in the web page to be displayed, so as to conveniently realize the association between the target element class and the element to be processed, thereby avoiding the problem of invalid event behavior added to the element to be processed.

[0064] Optionally, when the identification information does not belong to the target identification set, the operation of associating the target element class with the element to be processed in the web page to be displayed may specifically include:

[0065] S31. Register the target element class to obtain a replacement element that can be recognized by the web page.

[0066] S32: In the web page to be displayed, the element to be processed is replaced with the replacement element to associate the target element class with the element to be processed.

[0067] Wherein, when the identification information does not belong to the above target identification set, it indicates that the element to be processed is a custom element (EDITING:TUBER) in the webpage design process, and the custom element is not supported by the HTML5 standard. At this time, the element to be processed cannot be displayed normally in non-IE browsers. Further, the embodiment of the present invention can register the target element class through the registration interface (window.customElements.define) provided by the HTML5 standard, so that the webpage element obtained by registration is supported by HTML5, and the webpage element obtained by registration can be used as a replacement element.

[0068] Furthermore, the replacement element can be used to replace the element to be processed in the web page to be displayed, so that the target element class can be associated with the element to be processed, and the replacement element can be identified and displayed, and the added event behavior can also be realized.

[0069] For example, if the element to be processed is a custom element EDITING:TUBER, and the generated custom element class is EditingTuber, then the embodiment of the present invention can use the registration interface window.customElements.define('editing-tuber', EditingTuber) to register a replacement element named editing-tuber. After registration, the page can identify <editing-tuber>Tag web page elements, you can use <editing-tuber>Replace EDITING:TUBER in the page.

[0070] Optionally, the embodiment of the present invention may further include:

[0071] When the identification information of the element to be processed belongs to a target identification set, the class of the element to be processed is determined as a target category, and a root element class whose category is the target category is created, and the target element class inherits the root element class; the target identification set contains element identifications of identifiable elements of the web page.

[0072] Wherein, when the identification information belongs to the above target identification set, the component file is usually an extension or customization of a common web page element. In this case, the class of the element to be processed can be determined as the target class, and the target class is used as the root, so that the target element class is integrated with the root element class. For example,

[0073]

[0074] Figure 2 Figure 2

[0075]

[0076]

[0077]

[0078]

[0079]

[0080]

[0081]

[0082]

[0083]

[0084]

[0085]

[0086]

[0087]

[0088]

[0089]

[0090]

[0091]

[0092]

[0093]

[0094]

[0095] Figure 3

[0096]

[0097]

[0098]

[0099]

[0100]

[0101]

[0102]

[0103]

[0104]

[0105]

[0106] The class of the element is HTMLTableElement. At this time, the extends keyword can be used to make the target element class inherit the HTMLTableElement class. In this way, the consistency of the target element class and the element to be processed can be guaranteed while creating the target element class. It is a structural diagram of a web page display device provided by an embodiment of the present invention. The device is applied to a browser that complies with the W3C standard. As shown, the device 20 may include: a first acquisition module 201, in response to a web page display request, based on the web page to be displayed corresponding to the web page display request, acquires a web page element with an event behavior added to the web page to be displayed as an element to be processed; a second acquisition module 202, for a web page declaration file corresponding to the element to be processed, and acquires the tag information of the event behavior added to the element to be processed based on the web page declaration file; the web page declaration file is a file incompatible with the W3C standard, and the web page declaration file is used to define the event behavior; a creation module 203, for creating a target element class, and setting the tag information of the target element class based on the tag information; an association module 204, for associating the target element class with the element to be processed in the web page to be displayed, and displaying the web page to be displayed. Optionally, the device further includes: a third acquisition module, used to acquire the identification information of the element to be processed; the above-mentioned association module is specifically used to: when the identification information belongs to the target identification set, set the target element class as the event behavior of the element to be processed in the web page to be displayed through the association interface to associate the target element class with the element to be processed; the target identification set contains element identifications of elements identifiable by the web page. Optionally, the above-mentioned association module is also specifically used to: when the identification information does not belong to the target identification set, register the target element class to obtain a replacement element identifiable by the web page; in the web page to be displayed, use the replacement element to replace the element to be processed to associate the target element class with the element to be processed. Optionally, the tag information includes method tags, attribute tags, event tags and behavior tags, and the second acquisition module includes: a conversion submodule, used to convert the content contained in the web page declaration file into a document node; a traversal submodule, used to traverse the converted document nodes, and sequentially obtain method nodes, attribute nodes, event nodes and behavior nodes based on the node identifier of each document node; a fourth acquisition submodule, used to obtain method tags, attribute tags, event tags and behavior tags based on the method nodes, attribute nodes, event nodes and behavior nodes. Optionally, the creation module is also specifically used to: set tag information consistent with the tag information in the target element class.Optionally, the device 20 further includes: an inheritance module, which is used to determine the class of the element to be processed as a target category when the identification information of the element to be processed belongs to a target identification set, and to create a root element class whose category is the target category, and to make the target element class inherit the root element class; the target identification set contains element identifications of elements that can be identified by the web page. In summary, the web page display device provided in the embodiment of the present invention, in response to a web page display request, obtains a web page element with event behavior added to the web page to be displayed as an element to be processed based on the web page to be displayed corresponding to the web page display request; obtains a web page declaration file corresponding to the element to be processed, and obtains tag information of the event behavior added to the element to be processed based on the web page declaration file; creates a target element class, and sets the tag information of the target element class based on the tag information; associates the target element class with the element to be processed in the web page to be displayed, and displays the web page to be displayed. By creating a target element class for the element to be processed, and setting the label information of the target element class based on the webpage declaration file corresponding to the element to be processed, the event behavior added for the element to be processed in the webpage declaration file can be encapsulated, and the target element class is the code obtained by encapsulation. In this way, by associating the element to be processed with the target element class in the webpage to be displayed, the event behavior can be directly added to the element to be processed in the webpage, and the event behavior is no longer added through the component file, avoiding the invalid problem caused by the sub-browser that complies with the W3C standard not supporting the addition of event behavior to the webpage element through the component file, and improving the webpage display effect. The present invention also provides an electronic device, see, comprising: a processor 301, a memory 302, and a computer program 3021 stored in the memory and executable on the processor, and the processor implements the webpage display method of the aforementioned embodiment when executing the program. The present invention also provides a readable storage medium, when the instructions in the storage medium are executed by the processor of the electronic device, the electronic device can execute the webpage display method of the aforementioned embodiment. For the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts refer to the partial description of the method embodiment. The algorithms and displays provided herein are not inherently related to any particular computer, virtual system or other device. Various general purpose systems may also be used together with the teachings based thereon. It is apparent from the above description that the structure required for constructing such systems is. In addition, the present invention is not directed to any particular programming language either. It should be understood that various programming languages ​​may be utilized to implement the content of the present invention described herein, and the above description of specific languages ​​is intended to disclose the best mode of the present invention. In the specification provided herein, a large number of specific details are described. However, it will be appreciated that embodiments of the present invention may be practiced without these specific details.In some instances, well-known methods, structures, and techniques are not shown in detail so as not to obscure the understanding of this specification. Similarly, it should be understood that in order to simplify the present invention and help understand one or more of the various inventive aspects, in the above description of the exemplary embodiments of the present invention, the various features of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. However, the disclosed method should not be interpreted as reflecting the following intention: the claimed invention requires more features than the features clearly recorded in each claim. More specifically, as reflected in the following claims, the inventive aspects are less than all the features of the single embodiment disclosed above. Therefore, the claims following the specific embodiment are hereby explicitly incorporated into the specific embodiment, wherein each claim itself is a separate embodiment of the present invention. Those skilled in the art can understand that the modules in the devices in the embodiments can be adaptively changed and set in one or more devices different from the embodiment. The modules or units or components in the embodiments can be combined into one module or unit or component, and in addition, they can be divided into multiple submodules or subunits or subcomponents. All features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed in this specification (including the accompanying claims, abstracts and drawings) may be combined in any combination, except that at least some of such features and / or processes or units are mutually exclusive. Unless otherwise explicitly stated, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature that provides the same, equivalent or similar purpose. The various component embodiments of the present invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. It should be understood by those skilled in the art that a microprocessor or a digital signal processor (DSP) may be used in practice to implement some or all functions of some or all components in the sorting device according to the present invention. The present invention may also be implemented as a device or apparatus program for executing part or all of the methods described herein. Such a program for implementing the present invention may be stored on a computer-readable medium, or may be in the form of one or more signals. Such a signal may be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form. It should be noted that the above embodiments illustrate the present invention rather than limit the present invention, and that those skilled in the art may design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between brackets shall not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements.The present invention can be implemented by means of hardware including several different elements and by means of a suitably programmed computer. In a unit claim that lists several devices, several of these devices may be embodied by the same hardware item. The use of the words first, second, and third, etc. does not indicate any order. These words may be interpreted as names. A person skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system, device and unit described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the scope of protection of the present invention. The above description is only a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed by the present invention, which shall be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be subject to the scope of protection of the claims. < / destructor> < / constructor> < / public:attach> < / public:event> < / public:method> < / public:property>

Claims

1. A web page display method, characterized in that: Applied to a browser that complies with the W3C standard, the method includes: In response to a web page display request, based on a web page to be displayed corresponding to the web page display request, obtaining a web page element to which an event behavior is added in the web page to be displayed as an element to be processed; Obtaining a webpage declaration file corresponding to the element to be processed, and obtaining label information of the event behavior added to the element to be processed based on the webpage declaration file; the webpage declaration file is a file incompatible with the W3C standard, and the webpage declaration file is used to define the event behavior; Creating a target element class, and setting tag information of the target element class based on the tag information; Obtaining identification information of the element to be processed; Based on whether the identification information belongs to a target identification set, the target element class is associated with the element to be processed in the web page to be displayed, and the web page to be displayed is displayed; the target identification set includes element identifications of identifiable elements of the web page.

2. The method according to claim 1, characterized in that: In a case where the identification information belongs to the target identification set, associating the target element class with the element to be processed in the web page to be displayed includes: In the web page to be displayed, the target element class is set as the event behavior of the element to be processed through an association interface to associate the target element class with the element to be processed.

3. The method according to claim 1, characterized in that In a case where the identification information does not belong to the target identification set, associating the target element class with the element to be processed in the web page to be displayed includes: Registering the target element class to obtain a replacement element that can be recognized by the web page; In the web page to be displayed, the element to be processed is replaced by the replacement element to associate the target element class with the element to be processed.

4. The method according to claim 1, characterized in that: The tag information includes method tags, attribute tags, event tags, and behavior tags. The step of acquiring the tag information of the event behavior added to the element to be processed based on the webpage declaration file includes: Convert the content contained in the webpage declaration file into a document node; Traverse the converted document nodes, and obtain method nodes, attribute nodes, event nodes, and behavior nodes in sequence based on the node identifiers of each document node; Based on the method nodes, attribute nodes, event nodes and behavior nodes, method tags, attribute tags, event tags and behavior tags are obtained respectively.

5. The method according to claim 4, characterized in that: The step of setting the tag information of the target element class based on the tag information includes: Tag information consistent with the tag information is set in the target element class.

6. The method according to claim 5, characterized in that: The method further comprises: When the identification information of the element to be processed belongs to a target identification set, the class of the element to be processed is determined as a target category, and a root element class whose category is the target category is created, and the target element class inherits the root element class; the target identification set contains element identifications of identifiable elements of the web page.

7. A web page display device, characterized in that: Applied to a browser that complies with the W3C standard, the device comprises: A first acquisition module, in response to a web page display request, acquires a web page element with an event behavior added in the web page to be displayed as an element to be processed based on the web page to be displayed corresponding to the web page display request; A second acquisition module is used for a webpage declaration file corresponding to the element to be processed, and acquires label information of the event behavior added to the element to be processed based on the webpage declaration file; the webpage declaration file is a file incompatible with the W3C standard, and the webpage declaration file is used to define the event behavior; A creation module, used for creating a target element class and setting tag information of the target element class based on the tag information; A third acquisition module is used to obtain the identification information of the element to be processed; The association module is used to associate the target element class with the element to be processed in the web page to be displayed based on whether the identification information belongs to a target identification set, and display the web page to be displayed; the target identification set contains element identifications of identifiable elements of the web page.

8. The device according to claim 7, characterized in that: The device also includes: The association module is specifically used to: when the identification information belongs to the target identification set, set the target element class as the event behavior of the element to be processed in the web page to be displayed through the association interface to associate the target element class with the element to be processed.

9. The device according to claim 8, characterized in that: The association module is further specifically used for: In the case where the identification information does not belong to the target identification set, registering the target element class to obtain a replacement element identifiable by the web page; In the web page to be displayed, the element to be processed is replaced by the replacement element to associate the target element class with the element to be processed.

10. The device according to claim 7, characterized in that: The tag information includes method tags, attribute tags, event tags, and behavior tags. The second acquisition module includes: A conversion submodule, used to convert the content contained in the webpage declaration file into a document node; The traversal submodule is used to traverse the converted document nodes, and obtain the method nodes, attribute nodes, event nodes and behavior nodes in turn based on the node identifier of each document node; The fourth acquisition submodule is used to respectively acquire a method tag, an attribute tag, an event tag and a behavior tag based on the method node, the attribute node, the event node and the behavior node.

11. The device according to claim 10, characterized in that: The creation module is further specifically used for: Tag information consistent with the tag information is set in the target element class.

12. The device according to claim 11, characterized in that: The device also includes: An inheritance module is used to determine the class of the element to be processed as a target category when the identification information of the element to be processed belongs to a target identification set, and to create a root element class whose category is the target category, and to make the target element class inherit the root element class; the target identification set contains element identifications of identifiable elements on the web page.

13. An electronic device, characterized in that: include: A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 6 when executing the program.

14. A readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Page height self-adaptation method and apparatus

    CN106610824A

  • Method for synchronously binding an external behavior to a web page element

    US20080229189A1