Webpage display method, electronic equipment, computer readable storage medium and computer program product

By maintaining a compatible code base in the web service device and generating target compatible codes based on browser information, the problem of inconsistent display of web pages on different browsers is solved, and efficient and comprehensive web page compatible display is achieved.

CN119760265APending Publication Date: 2025-04-04BEIJING TOPSEC NETWORK SECURITY TECH +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411825654.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-12
Publication Date
2025-04-04

AI Technical Summary

Technical Problem

The prior art is difficult to achieve correct and consistent display of web pages on different browsers, resulting in browser compatibility issues.

Method used

By maintaining the web page code and compatible code base in the web service device, the target compatible code is generated based on the browser information to ensure that the web page code is adapted to different browsers.

Benefits of technology

It realizes cross-browser-compatible display of web pages on all types of browsers, reducing maintenance costs and improving display consistency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119760265A_ABST
    Figure CN119760265A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a webpage display method, electronic equipment, a computer readable storage medium and a computer program product, a webpage service device selects and sends an adaptive webpage code and a target compatible code according to browser information of a webpage display device, so that the problem of cross-browser compatibility is effectively solved; and meanwhile, the problems of performance bottleneck, code redundancy, influence on webpage loading speed and the like possibly caused by directly embedding a large number of compatible codes into webpage codes are avoided, so that the webpage can be more widely adapted to various browsers, and the compatibility of the webpage is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of Internet technology, and in particular to a web page display method, an electronic device, a computer-readable storage medium, and a computer program product. Background Art

[0002] In the field of web development, browser compatibility has always been an important challenge faced by developers. With the rapid development of Internet technology and the diversification of user needs, many browsers have emerged on the market, such as Google Chrome, MozillaFirefox, Microsoft Edge, Safari, and a large number of customized browsers based on the Chromium kernel. When these browsers parse and render web standards such as HTML, CSS, and JavaScript, due to differences in their respective implementation methods and different levels of support for the standards, the display effects and functionality of the same web page on different browsers often differ significantly.

[0003] Although there are some browser compatibility solutions in the relevant technology that can alleviate compatibility issues to a certain extent, these solutions have limitations such as high maintenance costs and difficulty in fully covering all compatibility issues. Therefore, the industry urgently needs a more efficient and comprehensive web page display method that can automatically adapt to the characteristics of different browsers and ensure that web pages can be displayed correctly and consistently on all browsers. Summary of the invention

[0004] The purpose of the embodiments of the present application is to provide a web page display method, an electronic device, a computer-readable storage medium, and a computer program product, so as to achieve the technical effect of efficiently and accurately displaying web pages in accordance with the characteristics of different browsers.

[0005] In a first aspect, an embodiment of the present application provides a web page display method, wherein a web page display device is communicatively connected to a web page service device, and the web page service device maintains a web page code and a compatible code library; the method is applied to the web page service device; the method comprises:

[0006] In response to a web page access request sent by the web page display device through a browser, the web page code of the target web page is generated, and browser information is obtained; the browser information is used to indicate the type and / or version of the browser;

[0007] Based on the browser information, determining a target compatible code from the compatible code library; the target compatible code is used to ensure that the web page code is compatible with the browser;

[0008] The web page code and the target compatible code are sent to the web page display device, and the web page code and the target compatible code are used to display the web page after compatibility processing on the web page display device.

[0009] In the above implementation process, the web page service device can determine the web page code of the target web page according to the access request sent by the browser, and intelligently identify the type and / or version of the browser, and select the corresponding target compatible code from the compatible code library to ensure that the web page code can be adapted and correctly displayed on all types of browsers, thereby solving the browser compatibility problem and realizing cross-browser compatible display of the web page.

[0010] Furthermore, obtaining browser information includes:

[0011] Sending an identification code to the web page display device, wherein the identification code is used to instruct the web page display device to run the identification code to obtain the browser information;

[0012] The browser information sent by the web page display device is received.

[0013] In the above implementation process, by sending the identification code to the web page display device and receiving the browser information returned by the device, the detailed information of the current browser can be effectively obtained.

[0014] Furthermore, the web page access request carries the browser information, and the browser information is obtained by the web page display device by running a locally pre-stored identification code.

[0015] In the above implementation process, the web page access request directly carries the browser information obtained by the web page display device by running the locally pre-stored identification code. This method can efficiently obtain the browser information.

[0016] Further, the webpage service device stores a correspondence between compatible codes and hash values; and determining a target compatible code from the compatible code library based on the browser information includes:

[0017] Generate a hash value corresponding to the browser information;

[0018] Based on the hash value and the corresponding relationship, the target compatible code is determined from the compatible code library.

[0019] In the above implementation process, the web page service device can quickly match the corresponding target compatible code from the compatible code library according to the hash value of the browser information through the stored correspondence between the compatible code and the hash value.

[0020] Furthermore, the web page service device includes a website service device and a compatible service device; wherein the website service device maintains the web page code; the compatible service device maintains the compatible code library; the website service device is used to respond to the web page access request and generate the web page code, and the compatible service device is used to obtain the browser information and determine the target compatible code based on the browser information.

[0021] In the above implementation process, by handing over web page generation and compatibility processing to independent website service devices and compatible service devices respectively, not only the maintainability and reusability of compatible codes are improved, but also the overall efficiency of web page services is effectively improved.

[0022] Furthermore, the method further comprises:

[0023] In response to the compatible code insertion instruction, new compatible code is added to the compatible code library.

[0024] In the above implementation process, by responding to the compatible code insertion instruction and adding new code to the compatible code library, newly emerging compatibility issues can be easily dealt with without modifying and redeploying the web page code, thereby enhancing the maintainability of the compatible code.

[0025] Furthermore, the browser information is also used to indicate information of an operating system used by the web page display device.

[0026] In the above implementation process, the browser information also includes the operating system information, so that the web page service can more accurately identify and adapt to the web page display requirements in different operating system environments.

[0027] A second aspect of an embodiment of the present application provides an electronic device, the electronic device comprising:

[0028] processor;

[0029] a memory for storing processor-executable instructions;

[0030] Wherein, when the processor calls the executable instruction, any method described in the first aspect is implemented.

[0031] A third aspect of an embodiment of the present application provides a computer-readable storage medium having computer instructions stored thereon, which, when executed by a processor, implement the steps of any method described in the first aspect.

[0032] A fourth aspect of the embodiments of the present application provides a computer program product, wherein the computer program product includes a computer program, and when the computer program is executed by a processor, any method described in the first aspect is implemented. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0034] Figure 1 A flowchart of a web page display method provided in an embodiment of the present application;

[0035] Figure 2 A schematic diagram of communication interaction between a web page display device and a web page service device provided in an embodiment of the present application;

[0036] Figure 3 A schematic diagram of communication interaction between a web page display device, a website service device and a compatible service device provided in an embodiment of the present application;

[0037] Figure 4 A structural block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0038] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.

[0039] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.

[0040] In order to deal with the problem of browser compatibility, developers have tried a variety of browser compatibility solutions. For example, static processing, writing CSS styles and JavaScript scripts for specific browsers, can solve compatibility problems to a certain extent, but often requires a lot of manual adjustments according to different browsers, which is costly and inefficient to maintain. Furthermore, although conditional comment technology provides a means to load different code snippets according to browser type, its limitation is that it is mainly applicable to early Internet Explorer browsers, and it is incapable of compatibility processing for modern browsers. In addition, Polyfill technology achieves backward compatibility with new features by simulating these features on old versions or browsers that do not support certain new features. However, Polyfill technology also has corresponding technical problems: developers need to write corresponding Polyfill code for each incompatible feature, which not only increases the difficulty of development, but also makes it difficult to ensure that all possible compatibility issues are covered. In summary, although the relevant technologies have alleviated the compatibility problem to a certain extent, they generally have the disadvantages of high maintenance cost and difficulty in fully covering all compatibility issues.

[0041] In response to any of the above-mentioned problems, the present application provides a web page display method, referring to Figure 1 , Figure 1 A flowchart of a web page display method provided in an embodiment of the present application.

[0042] In this embodiment, the web page display device is in communication with the web page service device, and the web page service device maintains web page codes and a compatible code library; the method is applied to the web page service device; the method includes:

[0043] Step S10: in response to a web page access request sent by the web page display device through a browser, generating the web page code of the target web page and acquiring browser information; the browser information is used to indicate the type and / or version of the browser;

[0044] It should be noted that in the context of web browsing, web page display devices usually refer to user devices, which can be terminals such as computers and mobile phones that can run browsers. Users initiate access requests to a web page through browsers on these devices. The web page service device is responsible for responding to these access requests and providing corresponding web page content.

[0045] As an example, the web page serving device may be a single website server that stores and provides web page codes and has the functions of identifying browser information and processing compatible tasks.

[0046] As another example, a web page service device may be a server cluster, and in the configuration of the server cluster, multiple types of servers may be included to cope with different processing requirements. For example, a web page service device includes a website server and a system server. Among them, the website server is mainly responsible for storing and providing web page codes, that is, the basic composition of the web page content that users can eventually see. The core responsibility of the system server is to identify the information of the browser, including the type and version of the browser, and to process compatibility tasks based on this information. Specifically, the system server selects appropriate compatible codes from a pre-stored compatible code library based on the characteristics of the browser. The role of these compatible codes is to ensure that the web page code can be displayed correctly on different browsers and solve compatibility issues caused by browser differences.

[0047] Specifically, when a user enters a URL or clicks a link through a browser on a web page display device (such as a computer, mobile phone, etc.), the browser will send a web page access request to the corresponding web page service device (such as a website server or server cluster). This request contains the URL (Uniform Resource Locator) of the web page that the user wants to access and possible other request parameters. After receiving this access request, the web page service device will first retrieve the web page code of the corresponding target web page from the stored web page resources based on the requested URL and other parameters. These web page codes are usually written by web standard technologies such as HTML (Hypertext Markup Language), CSS (Cascading Style Sheets), and JavaScript, which together define the structure, style, and behavior of the web page.

[0048] Exemplarily, while generating and preparing to send the web page code, the web page service device also extracts browser information from the browser's access request. This information is usually contained in the request header (HTTP Headers), especially the User-Agent field. The User-Agent string is a specific identifier that tells the server the type, version, operating system and other information of the browser that initiated the request. The obtained browser information is used for subsequent compatible code selection and web page rendering optimization. By parsing the User-Agent string, the web page service device can identify the type (such as Chrome, Firefox, Safari, etc.) and version (such as Chrome 99, Firefox 98, etc.) of the browser, thereby understanding the browser's support for Web standards and possible compatibility issues.

[0049] Step S20: Based on the browser information, determine a target compatible code from the compatible code library; the target compatible code is used to ensure that the web page code is compatible with the browser;

[0050] It should be noted that in web development, since different browsers have different ways of parsing and rendering web standards such as HTML, CSS, and JavaScript, developers need to write specific codes to ensure that web pages can be displayed correctly on different browsers. These specific codes are the compatible codes.

[0051] Compatible code library: a database that stores a large number of compatible codes for different operating systems, different browsers, and different browser versions. The compatible code library can store comprehensive compatible codes for various compatibility issues, without being limited by the amount of data. In this embodiment, the web page code and the compatible code are stored separately and sent independently to the web page display device to complete the rendering of the web page. This design avoids the problem of slow web page loading caused by directly embedding a large amount of compatible code into the web page code, reduces the burden when loading the web page, and improves the loading efficiency. Therefore, this embodiment can effectively deal with more browser compatibility issues and ensure the correct display of web pages on various browsers.

[0052] The main function of target compatibility code is to ensure that the web page code can be adapted and displayed correctly on the current browser. It can contain some specific CSS styles, JavaScript scripts or other types of code to solve compatibility issues caused by browser differences. For example, it contains some CSS prefixes, JavaScript patches or Polyfill codes for specific browsers.

[0053] In a specific implementation, based on the parsed browser information, a compatible code matching the browser type and version is searched in a compatible code library.

[0054] As an example, the browser information is also used to indicate information about the operating system used by the web page display device; the web page service device searches for matching compatible codes in a compatible code library according to the type and version of the browser and the operating system used by the web page display device.

[0055] Step S30: sending the web page code and the target compatible code to the web page display device, wherein the web page code and the target compatible code are used to display the web page after compatibility processing on the web page display device.

[0056] It is understandable that when the user's web page display device receives the web page code and the compatible code, it will render the web page according to the HTML, CSS, JavaScript and other elements contained in the web page code. Under the effect of the compatible code, the web page can be correctly and consistently displayed on the current browser without any compatibility issues caused by browser differences.

[0057] In this embodiment, the web page service device selects and sends the adapted web page code and the target compatible code according to the browser information of the web page display device, which effectively solves the cross-browser compatibility problem and avoids the performance bottlenecks, code redundancy, and impact on web page loading speed that may be caused by directly embedding a large amount of compatible code into the web page code. This enables the web page to be more widely adapted to multiple browsers and improves the compatibility of the web page.

[0058] Based on any of the above embodiments, the obtaining of browser information includes:

[0059] Sending an identification code to the web page display device, wherein the identification code is used to instruct the web page display device to run the identification code to obtain the browser information;

[0060] The browser information sent by the web page display device is received.

[0061] It should be noted that this embodiment describes the scenario in which the web service device responds to the web page access request from the web page display device for the first time. In this scenario, the web service device needs to send a specific identification code to the web page display device, and then the web page display device will save the identification code locally. When the web page display device initiates a web page access request to the web service device again, it will directly execute the locally stored identification code, and embed the browser information obtained by executing the code into the web page access request and send it to the web service device, thereby avoiding the need for the web service device to send the identification code again. Since the identification code sent by each web service device may be different, the above process is for the interaction between a specific web service device and a web page display device.

[0062] It should be understood that the identification code can be a JavaScript script or other code that can be executed by the browser. The purpose of the identification code is to let the browser execute it, so as to collect relevant information of the browser. This information includes but is not limited to the type, version, operating system, etc. of the browser.

[0063] Exemplarily, a user uses a browser to connect to a website, identifies a code to obtain browser information such as the browser's kernel information and version information, such as using JavaScript's navigator object to obtain the browser's version information and kernel information, and sends the target browser's relevant information to a web page service device via protocols such as http or https.

[0064] Specifically, the web page service device includes an information identification module. The information identification module may include a browser identification code, a browser version kernel information extraction code, etc. The server may receive the information through the header information of the HTTP response, the information embedded in the HTML page, and the information of the browser version kernel information. <script>标签、或者通过AJAX请求等方式发送这段识别代码。当网页显示装置,也即浏览器接收到这段识别代码后,它会执行这段代码。执行过程中,代码会访问浏览器的内置对象或API,以收集浏览器的相关信息。在浏览器执行完识别代码并收集到浏览器信息后,它会将这些信息发送回服务器,也即网页服务装置。由于网页显示装置在执行识别代码后会生成包含详尽浏览器相关信息的浏览器信息,但决定兼容代码适配性通常仅依赖于这些信息中的核心要素,例如浏览器的版本号、内核类型以及操作系统等。因此,当网页服务装置接收到这些浏览器信息后,可以将其传递给信息识别模块进行进一步处理。该信息识别模块的作用是从这些详尽的浏览器信息中提取出浏览器的版本号、内核类型、操作系统等关键要素。

[0065] 在本实施例中,通过直接在用户设备上运行识别代码,能够实时且准确地捕获浏览器及其环境的最新状态。同时,服务器在掌握了准确的浏览器信息后,可以更加精准地实施兼容性处理。

[0066] 在上述任意实施例的基础上,所述网页访问请求携带所述浏览器信息,所述浏览器信息是所述网页显示装置通过运行本地预存的识别代码得到的。

[0067] 需要说明的是,本实施例描述的是网页服务装置非首次响应来自网页显示装置的网页访问请求的场景。在此场景下,网页服务装置无需向网页显示装置发送识别代码,这是因为,在首次响应网页访问请求时,网页显示装置已经将识别代码存储在本地内存中了,在非首次响应的场景下,网页显示装置在发送网页访问请求之前,会先运行识别代码,并将运行识别代码确定的浏览器信息嵌入网页访问请求中发送给网页服务装置。

[0068] 作为一种例子,网页服务装置包括信息识别模块。由于网页显示装置在执行识别代码后生成的浏览器信息较为详尽,但决定兼容代码适配性的往往是这些信息中的核心要素,例如浏览器的版本号、内核类型以及操作系统等。因此,当网页服务装置接收到这些浏览器信息后,可以将其传递给信息识别模块进行进一步处理。该信息识别模块的作用是从这些详尽的浏览器信息中提取出浏览器的版本号、内核类型、操作系统等关键要素。

[0069] 在本实施例中,网页访问请求中直接携带了由网页显示装置(如浏览器)通过运行本地预存的识别代码获取的浏览器信息,提高了信息收集和传递的效率。

[0070] 在上述任意实施例的基础上,所述网页服务装置存储有兼容代码与哈希值的对应关系;所述基于所述浏览器信息,从所述兼容代码库中确定出目标兼容代码,包括:

[0071] 生成所述浏览器信息对应的哈希值;

[0072] 基于所述哈希值与所述对应关系,从所述兼容代码库中确定出所述目标兼容代码。

[0073] 需要说明的是,为了确保网页能够在不同的浏览器上正确显示并运行,网页服务装置会存储一系列兼容代码,而每部分代码针对不同的浏览器。为了实现高效的兼容代码匹配,网页服务装置内部存储了一个对应关系:兼容代码与哈希值的对应关系。其中,哈希是一种将任意长度的信息压缩到某一固定长度的消息摘要的函数,哈希值是经过哈希函数处理后得到的数据。通过比较哈希值而不是直接比较复杂的浏览器信息,可以显著提高匹配速度和效率。

[0074] 具体地,当网页服务装置接收到浏览器信息后,它会使用一种预定义的哈希算法(例如MD5、SHA-256等)对这些浏览器信息进行哈希处理,从而生成一个或多个哈希值。网页服务装置内部维护有一个兼容代码库,该库中存储了多种兼容代码及其各自对应的哈希值。为了找到与当前浏览器信息相匹配的兼容代码,网页服务装置会将生成的哈希值与兼容代码库中的哈希值进行比较。在一种情况下,网页服务装置针对浏览器信息生成一个唯一的哈希值,并基于这个唯一的哈希值在兼容代码库中查找对应的兼容代码。在另一种情况下,网页服务装置会针对浏览器信息中的不同组成部分(如内核信息、浏览器版本信息、操作系统信息等)分别生成多个哈希值。然后,分别查找每个哈希值在兼容代码库中对应的代码块,并将这些代码块组合起来,形成完整的、用于网页显示装置的目标兼容代码。

[0075] 如图2所示,图2为本申请实施例提供的一种网页显示装置与网页服务装置的通信交互示意图。图中描述了从浏览器访问网站页面到浏览器显示兼容处理后的网页内容的一系列步骤。首先,用户在用户设备(相当于网页显示装置)上通过浏览器输入网址或点击链接来访问网站页面,浏览器(相当于网页显示装置)会向网站服务器(相当于网页服务装置)发送一个网页访问请求,网站服务器接收到用户的网页访问请求后,向浏览器发送网页代码和识别代码;而后,浏览器运行识别代码,并将识别出的浏览器信息返回给网站服务器,其中,网站服务器包括由信息识别模块与兼容处理模块构成。在信息识别模块接收到浏览器信息后,会从浏览器信息中提取出浏览器的版本号、内核类型以及操作系统等关键信息,并根据预置的算法生成这些关键信息对应的哈希值,将生成的哈希值传递给兼容处理模块,兼容处理模块根据哈希值确定出对应的兼容代码,并将兼容代码发送给浏览器,浏览器运行兼容代码重新加载网页,最终显示兼容处理后的正常网页。

[0076] 在本实施例中,一方面,通过哈希值进行匹配,避免了直接比较复杂的浏览器信息,显著提高了匹配速度和效率。另一方面,哈希算法的特性保证了即使浏览器信息稍有不同,生成的哈希值也会截然不同,从而确保了匹配的准确性。最后,随着浏览器版本的更新和新浏览器的出现,只需将新的兼容代码及其对应的哈希值添加到兼容代码库中,即可轻松扩展系统的兼容性。

[0077] 在上述任意实施例的基础上,所述网页服务装置包括网站服务装置和兼容服务装置;其中,所述网站服务装置维护有所述网页代码;所述兼容服务装置维护有所述兼容代码库;所述网站服务装置用于响应所述网页访问请求并生成所述网页代码,所述兼容服务装置用于获取所述浏览器信息并基于所述浏览器信息确定所述目标兼容代码。

[0078] 需要说明的是,为了解耦网页代码与兼容代码,进一步提高兼容系统的可维护性及重用性,网页服务装置被划分为两个主要部分:网站服务装置和兼容服务装置。其中,兼容服务装置可以同时处理多个网站服务装置的兼容任务。

[0079] 网站服务装置的主要职责是维护和管理网页代码。这些网页代码是构成网页的基本元素,包括HTML、CSS、JavaScript等文件。当接收到客户端(即网页显示装置)的网页访问请求时,网站服务装置会根据请求的内容生成相应的网页代码,并将其发送给客户端进行渲染和显示。

[0080] 兼容服务装置的主要职责是处理与浏览器兼容性相关的问题。它维护了一个兼容代码库,其中包含了针对不同浏览器和浏览器版本的优化代码。当接收到客户端发送的浏览器信息时,兼容服务装置会根据这些信息确定并返回相应的目标兼容代码。此外,兼容服务装置可以包括信息识别模块与兼容处理模块,信息识别模块用于提取浏览器信息中的关键信息,如浏览器的版本号、内核类型、操作系统等,还用于生成这些关键信息对应的哈希值,并将该哈希值发送给兼容处理模块;兼容处理模块用于根据哈希值确定出对应的目标兼容代码。兼容处理模块为预置的存储和处理各种浏览器及各种浏览器不同版本兼容性问题的功能模块。如IE8及以下版本的IE浏览器不支持JavaScript语言的forEach函数的使用。处理该兼容问题的一种方法可以是为Array对象增加一个forEach方法,具体代码实现可以是"Array.prototype.forEach=function forEach(…){…}”,其中,Array对象及其方法是现代浏览器普遍支持的JavaScript对象,prototype属性是Array对象实现继承的属性,"…”是省略的处理代码。兼容处理模块会将此类兼容问题处理代码及此代码对应的浏览器版本记录于存储单元中。当兼容处理模块识别出浏览器信息为IE8及以下版本的IE浏览器时会将存储单元中的"Array.prototype.forEach=function forEach(…){…}”兼容代码返回给网页显示装置。而当浏览器兼容处理模块识别出浏览器信息不是IE浏览器则不会返回"Array.prototype.forEach=function forEach(…){…}”兼容代码。兼容处理模块使用的技术原理可以包括但不限于使用增加预置函数方法、重写预置函数方法的方式处理浏览器兼容问题。兼容处理模块可增设新型或新版浏览器可能存在的兼容数据。在具体实现中,兼容处理模块接收到浏览器的浏览器信息后,生成浏览器的兼容脚本代码信息(即兼容代码),并将兼容脚本代码信息返回给浏览器(相当于网页显示装置)。其中,兼容脚本代码信息可以为处理浏览器兼容问题的js、css等脚本代码。

[0081] 可理解的是,网站服务装置和兼容服务装置在网页服务装置中协同工作,共同处理客户端的网页访问请求。当客户端发送请求时,网站服务装置首先生成网页代码,并将其发送给客户端。同时,兼容服务装置会获取浏览器信息,并确定相应的目标兼容代码。这些兼容代码可以嵌入到网页代码中,或者作为单独的脚本文件发送给客户端执行。将网页服务装置划分为网站服务装置和兼容服务装置,实现了功能的模块化和解耦,提高了系统的可扩展性和可维护性。另外,通过并行处理网页生成和兼容代码确定的任务,提高了系统的处理速度和响应能力。

[0082] 作为一种例子,识别代码中嵌入有兼容服务装置的IP地址。若网站服务装置首次响应来自某个网页显示装置的网页访问请求,网站服务装置会将兼容服务装置的IP地址嵌入在识别代码中,指示网页显示装置运行识别代码确定浏览器信息,并基于兼容服务装置的IP地址将浏览器信息发送给兼容服务装置,以使兼容服务装置获取浏览器信息并基于浏览器信息确定标兼容代码发送给网页显示装置。

[0083] 作为另一种例子,识别代码中嵌入有兼容服务装置的IP地址。若网站服务装置非首次响应来自某个网页显示装置的网页访问请求,意味着网页显示装置本地内存中预存有在首次与网站服务装置通信交互时保存下来的识别代码,在这种情况下,网页显示装置会在再次向网站服务装置发送网页访问请求之前,运行识别代码,确定浏览器信息,在向网站服务装置发送网页访问请求的同时,基于识别代码中携带的兼容服务装置的IP地址将浏览器信息发送给兼容服务装置,以使兼容服务装置获取浏览器信息并基于浏览器信息确定标兼容代码发送给网页显示装置。

[0084] 作为另一种例子,识别代码中未嵌入有兼容服务装置的IP地址。在这种情况下,网站服务装置与兼容服务装置通信连接,网页显示装置不与兼容服务装置通信。若网站服务装置首次响应来自某个网页显示装置的网页访问请求,网站服务装置会将不包含兼容服务装置IP地址的识别代码发送给网页显示装置,指示网页显示装置运行识别代码确定浏览器信息,并发送给网站服务装置,而后,网站服务装置再将浏览器信息发送给兼容服务装置,以使兼容服务装置获取浏览器信息并基于浏览器信息确定标兼容代码发送给网页显示装置。若网站服务装置非首次响应来自某个网页显示装置的网页访问请求,意味着网页显示装置本地内存中预存有在首次与网站服务装置通信交互时保存下来的识别代码,且该识别代码不包含兼容服务装置的IP地址,在这种情况下,网页显示装置会在再次向网站服务装置发送网页访问请求之前,运行识别代码,确定浏览器信息,并将浏览器信息与网页访问请求一同发送给网站服务装置,而后,网站服务装置再将浏览器信息发送给兼容服务装置,以使兼容服务装置获取浏览器信息并基于浏览器信息确定标兼容代码发送给网页显示装置。

[0085] 如图3所示,图3为本申请实施例提供的一种网页显示装置与网站服务装置及兼容服务装置的通信交互示意图。图中示出了用户在用户设备上通过浏览器访问网站页面,到浏览器最终显示网页的一系列步骤。用户首先在用户设备(相当于网页显示装置)上使用浏览器输入网址或点击链接访问网站页面,网站服务器(相当于网站服务装置)接收到用户的访问请求后,会向浏览器(相当于网页显示装置)发送网页代码和识别代码;而后,浏览器运行识别代码,并返回识别出的浏览器信息给系统服务器,其中,系统服务器(相当于兼容服务装置)由信息识别模块与兼容处理模块构成。在信息识别模块接收到浏览器信息后,会从浏览器信息中提取出浏览器的版本号、内核类型以及操作系统等关键信息,并根据预置的算法生成这些关键信息对应的哈希值,将生成的哈希值传递给兼容处理模块,兼容处理模块根据哈希值确定出对应的兼容代码,并将兼容代码发送给浏览器,浏览器运行兼容代码重新加载网页,最终显示兼容处理后的正常网页。

[0086] 在本实施例中,网页服务装置通过分离为网站服务装置和兼容服务装置,实现了网页代码与兼容代码库的独立维护。这样的设计旨在提高系统的可维护性和复用性。当需要更新兼容代码或添加对新浏览器的支持时,只需对兼容服务装置进行调整,而无需改动网站服务装置,大大提高了代码的复用性和系统的灵活性。

[0087] 在上述任意实施例的基础上,所述方法还包括:

[0088] 响应于兼容代码插入指令,在所述兼容代码库中新增兼容代码。

[0089] 需要说明的是,在相关技术中,为解决浏览器兼容问题,需要将兼容代码嵌入到网页代码中一起发送给浏览器进行页面的渲染,这种方式使得网页代码庞大且冗长,影响加载速度,且当新增兼容代码时需要重新部署。而本实施例中,只需将兼容代码添加进独立维护的兼容代码库中即可,开发量大大减少,且不需要重新部署网页代码。

[0090] 此外,除了增加处理,还可以对兼容代码库中的兼容代码进行删改查等处理。

[0091] 在本实施例中,通过集中管理兼容代码,简化了系统的维护过程,降低了维护成本。同时,新添加的兼容代码可以被多个网页或网站服务重复使用,提高了兼容代码的复用率。

[0092] 在上述任意实施例的基础上,所述浏览器信息还用于指示所述网页显示装置所使用的操作系统的信息。

[0093] 可理解的是,不同的操作系统对网页渲染、事件处理、字体显示等方面可能存在细微的差异。这些差异可能导致网页在不同操作系统上的显示效果不一致,甚至可能出现布局错乱、功能失效等问题。因此,通过获取浏览器所使用的操作系统信息,可以更有针对性地选取或生成适应于该操作系统的兼容代码,以确保网页在不同操作系统上都能正确、一致地显示。

[0094] 需要说明的是,兼容代码库针对不同的浏览器版本、内核以及操作系统存储相应的兼容代码。这是因为不同的浏览器版本、内核和操作系统组合可能对网页的支持程度不同,需要不同的兼容代码来确保网页的正确显示和功能实现。例如,某些浏览器可能支持最新的CSS特性,而另一些浏览器则可能需要使用特定的前缀或替代方案来实现相同的效果。同样,不同的操作系统可能对JavaScript的性能、内存管理等方面有不同的要求,兼容代码需要对不同维度的数据都进行考虑。

[0095] 在本实施例中,在确定兼容代码时,还考虑了操作系统对网页显示的影响,有助于确保网页在不同操作系统上都能呈现出一致且正确的显示效果,避免了因操作系统差异而导致的布局错乱等问题。

[0096] 基于上述任意实施例所述的方法,本申请还提供了如图4所示的一种电子设备的结构示意图。如图4,在硬件层面,该电子设备包括处理器、内部总线、网络接口、内存以及非易失性存储器,当然还可能包括其他业务所需要的硬件。处理器从非易失性存储器中读取对应的计算机程序到内存中然后运行,以实现上述任意实施例所述的方法。

[0097] 基于上述任意实施例所述的方法,本申请还提供了一种计算机存储介质,存储介质存储有计算机程序,计算机程序被处理器执行时可用于执行上述任意实施例所述的方法。

[0098] 基于上述任意实施例所述的方法,本申请还提供了一种计算机程序产品,所述计算机程序产品包括一个或多个计算机程序或指令。所述计算机程序或指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输。所述计算机程序被处理器执行时实现上述任意实施例所述的方法。

[0099] 在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法,也可以通过其它的方式实现。以上所描述的装置实施例仅仅是示意性的,例如,附图中的流程图和框图显示了根据本申请的多个实施例的装置、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段或代码的一部分,所述模块、程序段或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现方式中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个连续的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和 / 或流程图中的每个方框、以及框图和 / 或流程图中的方框的组合,可以用执行规定的功能或动作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。

[0100] 另外,在本申请各个实施例中的各功能模块可以集成在一起形成一个独立的部分,也可以是各个模块单独存在,也可以两个或两个以上模块集成形成一个独立的部分。

[0101] 所述功能如果以软件功能模块的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。

[0102] 以上所述仅为本申请的实施例而已,并不用于限制本申请的保护范围,对于本领域的技术人员来说,本申请可以有各种更改和变化。凡在本申请的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请的保护范围之内。应注意到:相似的标号和字母在下面的附图中表示类似项,因此,一旦某一项在一个附图中被定义,则在随后的附图中不需要对其进行进一步定义和解释。

[0103] 以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应所述以权利要求的保护范围为准。

[0104] 需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语"包括”、"包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句"包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。< / script>

Claims

1. A web page display method, characterized in that: The web page display device is communicatively connected with the web page service device, and the web page service device maintains the web page code and the compatible code library; The method is applied to the web page service device; the method comprises: In response to a web page access request sent by the web page display device through a browser, the web page code of the target web page is generated, and browser information is obtained; the browser information is used to indicate the type and / or version of the browser; Based on the browser information, determining a target compatible code from the compatible code library; the target compatible code is used to ensure that the web page code is compatible with the browser; The web page code and the target compatible code are sent to the web page display device, and the web page code and the target compatible code are used to display the web page after compatibility processing on the web page display device.

2. The method according to claim 1, characterized in that The obtaining of browser information includes: Sending an identification code to the web page display device, wherein the identification code is used to instruct the web page display device to run the identification code to obtain the browser information; The browser information sent by the web page display device is received.

3. The method according to claim 1, characterized in that The web page access request carries the browser information, and the browser information is obtained by the web page display device by running a locally pre-stored identification code.

4. The method according to claim 1, characterized in that The webpage service device stores a correspondence between compatible codes and hash values; The step of determining a target compatible code from the compatible code library based on the browser information includes: Generate a hash value corresponding to the browser information; Based on the hash value and the corresponding relationship, the target compatible code is determined from the compatible code library.

5. The method according to claim 1, characterized in that The web page service device includes a website service device and a compatible service device; wherein the website service device maintains the web page code; the compatible service device maintains the compatible code library; the website service device is used to respond to the web page access request and generate the web page code, and the compatible service device is used to obtain the browser information and determine the target compatible code based on the browser information.

6. The method according to claim 1, characterized in that The method further comprises: In response to the compatible code insertion instruction, new compatible code is added to the compatible code library.

7. The method according to claim 1, characterized in that The browser information is also used to indicate information about the operating system used by the web page display device.

8. An electronic device, characterized in that: The electronic device comprises: processor; a memory for storing processor-executable instructions; Wherein, when the processor calls the executable instruction, the method described in any one of claims 1-7 is implemented.

9. A computer-readable storage medium, characterized in that: Computer instructions are stored thereon, and when the computer instructions are executed by a processor, the steps of any method described in claims 1-7 are implemented.

10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.