CN109542501B - Browser table compatibility method and device, computer equipment and storage medium - Google Patents

Browser table compatibility method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN109542501B
CN109542501B CN201811252693.8A CN201811252693A CN109542501B CN 109542501 B CN109542501 B CN 109542501B CN 201811252693 A CN201811252693 A CN 201811252693A CN 109542501 B CN109542501 B CN 109542501B
Authority
CN
China
Prior art keywords
browser
record
input control
script
preset
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811252693.8A
Other languages
Chinese (zh)
Other versions
CN109542501A (en
Inventor
黄春岑
李培光
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN201811252693.8A priority Critical patent/CN109542501B/en
Publication of CN109542501A publication Critical patent/CN109542501A/en
Application granted granted Critical
Publication of CN109542501B publication Critical patent/CN109542501B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management

Abstract

The invention discloses a browser table compatible method, a browser table compatible device, a computer device and a storage medium, wherein the method comprises the following steps: detecting version information of a current browser to obtain a browser version number; if the browser version number is lower than a preset version number threshold value, detecting a table tag in an HTML page, and acquiring a response position of a table input control corresponding to the table tag; shielding a response function of the form input control at a response position of the form input control, and inserting a preset compatible script; receiving a table operation message transmitted from the compatible script, storing a serial number of a record where a cursor is located in a table corresponding to the table label, and acquiring a table operation type from the table operation message; and reordering the records in the table according to the table operation type. The technical scheme of the invention solves the problems that other data in the table are disordered in sequencing and the background cannot acquire the front-end data correctly when the rows or columns of the table in the low-version browser are added or deleted.

Description

Browser table compatibility method and device, computer equipment and storage medium
Technical Field
The present invention relates to the field of information processing, and in particular, to a browser form compatibility method and apparatus, a computer device, and a storage medium.
Background
In the internet era, browser products are not only diversified, but also updated very quickly. Generally, every half year or so, there are some small upgrades to browser products; large version updates occur every two or so years. Because the information technology is updated very quickly, new products are often difficult to be compatible with the design of old products; some old software libraries are abandoned and replaced by more efficient and concise versions, which are strategies that many browser product providers have to adopt, and meanwhile, browser-based Web development follows up with new browser technologies, which brings compatibility problems for old Web systems still in service.
For example, for some large enterprises and public institutions, the Web system does not pay attention to new functions after browser upgrading, but pays attention to whether the whole Web system can provide services stably for a long time. Due to the fact that a software library used in the previous development of a Web front-end interface is abandoned by a new version, data confusion can occur when a user uses a new version browser to operate.
For example, the browser version below IE8 does not support the getelementsbyclname function, and when the browser version below IE8 is used, when adding or deleting lines to the table, the data labels in the added or deleted lines cannot be sequentially sorted, which causes the problem of data confusion when the backend acquires the front-end data. If the user continues to use the old version browser, the network security risk exists; if the user redesigns and develops the Web front-end interface, the cost is significant.
Disclosure of Invention
The embodiment of the invention provides a browser table compatibility method, a browser table compatibility device, computer equipment and a storage medium, and aims to solve the problems that when rows or columns of a table in a low-version browser are added or deleted, other data in the table are disordered in sequence, and a background cannot acquire data in the browser table correctly.
A browser form compatible method, comprising:
detecting version information of a current browser to obtain a browser version number;
if the browser version number is lower than a preset version number threshold value, detecting a form tag in an HTML page in the current browser, and acquiring a response position of a form input control corresponding to the form tag;
shielding a response function of the form input control at a response position of the form input control, and inserting a preset compatible script;
receiving a table operation message transmitted from the compatible script, storing a serial number of a record where a cursor is located in a table corresponding to the table tag, and acquiring a table operation type from the table operation message;
if the table operation type is a new adding operation, acquiring a new adding record to be inserted, inserting the new adding record into the record of the cursor, increasing the sequence number in an increasing mode on the basis of the sequence number of the record of the cursor to serve as the sequence number of the new adding record, and adding the sequence number of each cell included in each record after the new adding record to the number of the new adding record;
and if the table operation type is deleting operation, deleting the record where the cursor is located, and subtracting the number of the deleted records where the cursor is located from the sequence number of each cell contained in each record after the record where the cursor is located.
A browser form compatible device, comprising:
the version detection module is used for detecting the version information of the current browser to obtain the version number of the browser;
the target function position obtaining module is used for detecting a table tag in an HTML page in the current browser and obtaining a response position of a table input control corresponding to the table tag if the browser version number is lower than a preset version number threshold;
the target function replacement module is used for shielding the response function of the form input control at the response position of the form input control and inserting a preset compatible script;
the table operation acquisition module is used for receiving the table operation message transmitted from the compatible script, storing the serial number of the record of the cursor in the table corresponding to the table label and acquiring the table operation type from the table operation message;
the newly added record module is used for acquiring a newly added record to be inserted if the table operation type is a newly added operation, inserting the newly added record into the record in which the cursor is positioned, increasing the sequence number in an increasing mode on the basis of the sequence number of the record in which the cursor is positioned to serve as the sequence number of the newly added record, and adding the sequence number of each cell contained in each record after the newly added record to the number of the newly added record;
and the record deleting module is used for deleting the record where the cursor is located if the table operation type is the deleting operation, and subtracting the number of the records where the cursor is located from the serial number of each cell contained in each record after the record where the cursor is located.
A computer device comprising a memory, a processor and a computer program stored in said memory and executable on said processor, said processor implementing the steps of the above browser table compatibility method when executing said computer program.
A computer-readable storage medium, storing a computer program which, when executed by a processor, implements the steps of the above-described browser form compatibility method.
The browser table compatibility method, the browser table compatibility device, the computer equipment and the storage medium detect version information of a current browser to obtain a browser version number, and compare the browser version number with a preset threshold value to obtain a low-version browser needing to use the technical scheme; detecting a form tag in an HTML page in a current browser, acquiring a response position of a form input control corresponding to the form tag, inserting a compatible script with a form compatible function into the response position of the form input control, and shielding a response function of an original form input control; receiving a table operation message transmitted from the compatible script, storing a serial number of a record of a cursor in a table, and acquiring a table operation type from the table operation message; according to the operation type of the table and the sequence number recorded by the cursor, other cells in the table affected by the operation of the table are reordered, so that when rows or columns in the table are added or deleted in the low-version browser, the ordering of other data in the table is not disordered, a background server can accurately and conveniently acquire the data in the table of the low-version browser, and the compatibility of the low-version browser is improved. Meanwhile, the old Web system does not need to be redesigned and developed, and the development cost is saved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the description of the embodiments of the present invention will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to these drawings without inventive labor.
FIG. 1 is a diagram of an application environment of a browser form compatibility method according to an embodiment of the present invention;
FIG. 2 is a flow chart of a browser form compatibility method in an embodiment of the present invention;
FIG. 3 is a diagram illustrating the inherent ordering of data in a browser form before and after compatibility;
FIG. 4 is a flowchart of another implementation manner for step S3 in an embodiment of the present invention;
FIG. 5 is a diagram of a browser form compatible device in accordance with an embodiment of the present invention;
FIG. 6 is a schematic diagram of a computer device in an embodiment of the invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The browser form compatibility method provided by the present application can be applied to the application environment as shown in fig. 1, where a user communicates with a server through a browser on a client, the client and the server are connected through a network, and the network may be a wired network or a wireless network. The client is a computer terminal device, including but not limited to various personal computers, laptops, smart phones, tablet computers and portable wearable devices. A server is a server or cluster of servers that provides Web services. The browser form compatibility method provided by the embodiment of the invention is applied to the client.
In an embodiment, as shown in fig. 2, a browser form compatible method is provided, and a specific implementation flow thereof includes the following steps:
s1: and detecting the version information of the current browser to obtain the version number of the browser.
The version information of the browser is information related to functions provided by a browser product provider to inform a user of the currently used browser, and is generally in the form of a browser version number. For example, the browser version number of the IE11 browser from microsoft corporation is IE11.1198.14393.0, the browser version number of the Chrome browser from google corporation is Chrome 69.0.3497.100, and the browser version number of the open source browser, Firefox, is Firefox 61.0.2. The numbers before the first decimal point represent the major version number of the current browser, and the major version number is the main identification information used for distinguishing whether the browser supports a certain function.
Detecting the version information of the current browser can be realized by the browser executing a JavaScript script. The JavaScript script is an transliterated script language, is a dynamic type, weak type, prototype-based language and is internally provided with a support type. Its interpreter, called JavaScript engine, is a part of the browser, widely used in the scripting language of the client, and was originally used on the HTML web page to add dynamic functionality to the HTML web page.
Specifically, the version information character of the current browser can be acquired through a function navigator. For example, taking the IE11 browser as an example, the browser version number obtained by calling a function in JavaScript is "IE/11.1198.14393.0".
S2: and if the browser version number is lower than a preset version number threshold value, detecting a table tag in an HTML page in the current browser, and acquiring a response position of a table input control corresponding to the table tag.
The preset version number threshold is used for distinguishing whether the current browser needs to perform table compatibility operation, namely whether the internal ordering of the table data is disordered after the current browser adds or deletes rows or columns to the table.
For example, taking an IE browser as an example, if the preset version number threshold is IE8, using the following versions of IE8, such as IE7 or IE5, the following problems may be encountered when operating the table: if 5 rows of data exist in the original table, the internal ordering of the data in the table is 1, 2, 3, 4, 5, and after inserting one row between 3 and 4, the internal ordering of the data in the table is 1, 2, 3, 6, 4, 5. However, the background server takes the values of the data in the table from top to bottom according to the row number sequence of the table, the internal ordering of the taken data should be 1, 2, 3, 4, 5, 6, and the internal ordering of the currently taken data should be 1, 2, 3, 6, 4, 5, which brings trouble to a series of application operations of the background server. Similarly, when deleting a row, if the third row data is deleted, the inherent ordering of the data in the table becomes 1, 2, 4, 5, and correctly, should be 1, 2, 3, 4. Specifically, as shown in the schematic diagram of fig. 3, the intrinsic ordering of data in the table before and after compatibility is shown after the add/delete operation is performed on the table.
The preset version number threshold is distinguished according to the type of the browser. Types of browsers include Microsoft's IE browser, Google's Chrome browser, Firefox browser, apple's Safari browser, 360 browser, and so on. For example, if it is an IE browser, the preset version number threshold may be IE 11; if the browser is a Chrome browser, the preset version number threshold value can be Chrome 65; in the case of a Firefox browser, the preset version number threshold may be Firefox55, and so on.
Specifically, the browser version number is compared with a preset version number threshold, taking an IE browser as an example, if the current browser version number is IE/8.10.1120.11594.0 and the preset version number threshold is IE/11.1198.14393.0, then the characters in front of the first decimal point in the two character strings are compared, that is, the version number IE/8 of the current browser is lower than the preset version number threshold IE/11.
A form tab is a tab in an HTML page that identifies a form element and is to be parsed by the browser. Common table tags include < table >, < tr >, < td >, etc., where tag < table > represents a table, tag < tr > represents a row in the table, and tag < td > represents a column in the table.
In the HTML page, the form tab has a form input control corresponding thereto. The form input control receives a control for data entered by a user in an HTML page. The form input controls may be button controls, form controls, check box controls, radio box controls, and the like. The form input controls correspond to form labels. For example, a table < table > tag includes a number of < tr > tags and < td > tags, representing that a table is composed of a number of rows and columns, each row or column may contain a table input control. When the user operates the form input control, the client thus knows which row or column the user is operating on.
The response position of the form input control is a code segment which responds to the user after inputting the data through the form input control and is used for executing the operation of inputting the data through the form input control by the user. Specifically, the code segment may be a JavaScript statement. For example, a tab < td > includes a button control under the following code:
<td width=”20%”align=”center”>
<input type=”button”onclick=”add(this)”value=”+”>
</td>
wherein, input type is "button" to indicate that the form input control is a button control; onclick represents a mouse click event that responds to a button control; once is the response position of the form input control, here, the response position of the form input control is a response function with the function name add. The function body of the response function add may be defined elsewhere in the HTML file.
S3: and shielding the response function of the form input control at the response position of the form input control, and inserting a preset compatible script.
The response function of the form input control is a function of the responsive processing of the form input control. Taking the example that a button control is included under the tag < td > in step S2, the response function of the form input control is masked at the response position of the form input control, that is, the response function add is masked, so that the browser does not execute the add function. The preset compatible script is a JavaScript script used for replacing the response function add to the mouse click event.
In particular, the response function of the form input control may be annotated to mask the response function, such as using the annotator "< | of HTML! - - - - >; a return statement may also be added at the top of the body of the response function to return an empty set, representing that the response function does nothing. The preset compatible script automatically inserted by the client can be a function name, and the function body of the function can be defined at other positions in the HTML, so that the response to the form input control is changed from the original response function to the inserted preset compatible script for response.
S4: and receiving a table operation message transmitted from the compatible script, storing the serial number of the record of the cursor in the table corresponding to the table label, and acquiring the table operation type from the table operation message.
The form operation message is a message which is responded by the compatible script and sent to the client after the user operates the form input control, such as triggering a mouse click event. The table operation message includes a table operation type. The table operation types are divided into adding operation and deleting operation, wherein the adding operation represents adding rows or columns of the table; a delete operation represents a deletion of a row or column of a table. The data type of the table operation type may be a character type, an integer type, a boolean type, or the like. For example, if the table operation type is represented as an integer type, then integer 0 may represent an add operation and integer 1 may represent a delete operation; if the table operation type is represented as a character type, the character "+" may represent a new addition operation and the character "-" may represent a deletion operation.
When a user adds or deletes rows or columns of the table through the table input control, the row number or column number corresponding to the operated row or column is the serial number of the record in which the cursor is located in the table.
Specifically, because the form input control corresponds to the form tag, when a user adds or deletes a row or a column of the form through the form input control, the form input control sends a message to an analyzer of the browser, where the message sent by the form input control to the analyzer of the browser includes a row number or a column number corresponding to the operated row or column, so that the client can know which row or column the user operates on, and store the sequence number of the record where the cursor is located in the form corresponding to the form tag.
S5: and if the table operation type is a new adding operation, acquiring a new adding record to be inserted, inserting the new adding record into the record in which the cursor is positioned, increasing the sequence number of the new adding record progressively on the basis of the sequence number of the record in which the cursor is positioned, and adding the sequence number of each cell contained in each record after the new adding record to the number of the new adding record.
And judging the table operation type acquired in the table operation message, and if the data type of the table operation type is an integer, determining that the current operation is a newly added record operation when the value of the table operation type is detected to be 0.
And the client receives data transmitted from the form input control, wherein the data is the newly added record, and the newly added record is added behind the record of the cursor. The newly added record can be a row or N rows, and can also be a column or N columns. A table may be composed of N rows and M columns, and if a row of records is added, the row of records has M cells, that is, the cells correspond to the M columns of the table; if a column record is added, the column record has N cells, i.e. the cell corresponds to N rows of the table. Wherein N and M are integers greater than 1. Therefore, when performing add/delete operations on rows and columns of the table, the sequence numbers of all cells in the affected records need to be modified.
Specifically, if there is a table with 5 rows and 5 columns, the internal ordering of records in the table is 1, 2, 3, 4, 5, and when a new row of records is added between 3 and 4, the record where the cursor is located is 3; after the new record is inserted into 3, the sequence numbers of the original 4 and 5 records are respectively changed to 5 and 6, i.e. the sequence numbers of 5 cells in the original 4 and 5 records are both changed to 5 and 6. Similarly, if the number of newly added records between 3 and 4 is 3, the record of the cursor is 3; after the new record is inserted into 3, the sequence numbers of the original 4 and 5 records are respectively changed to 7 and 8.
S6: if the table operation type is a delete operation, deleting the record where the cursor is located, and subtracting the number of the records where the deleted cursor is located from the sequence number of each cell contained in each record after the record where the cursor is located.
And judging the table operation type acquired in the table operation message, and if the data type of the table operation type is an integer type, determining that the current operation is the record deleting operation when the value of the table operation type is detected to be 1.
Specifically, if there is a table with 5 rows and 5 columns, the internal ordering of records in the table is 1, 2, 3, 4, 5, and when the record where 3 is located is to be deleted, the record where the cursor is located is 3; the sequence numbers of the original 4 and 5 records are respectively changed to 3 and 4, that is, the sequence numbers of 5 cells in the original 4 and 5 records are changed to 3 and 4.
In this embodiment, the version information of the current browser is detected to obtain a browser version number, and the browser version number is compared with a preset threshold value to obtain a low-version browser that needs to use the technical scheme; detecting a form tag in an HTML page in a current browser, acquiring a response position of a form input control corresponding to the form tag, inserting a compatible script with a form compatible function into the response position of the form input control, and shielding a response function of an original form input control; receiving a table operation message transmitted from the compatible script, storing a serial number of a record of a cursor in a table, and acquiring a table operation type from the table operation message; according to the operation type of the table and the sequence number recorded by the cursor, other cells in the table affected by the operation of the table are reordered, so that when rows or columns in the table are added or deleted in the low-version browser, the ordering of other data in the table is not disordered, a background server can accurately and conveniently acquire the data in the table of the low-version browser, and the compatibility of the low-version browser is improved. Meanwhile, the old Web system does not need to be redesigned and developed, and the development cost is saved.
Further, in the embodiment, in step S3, namely at the response position of the form input control, the response function of the form input control is masked, and a preset compatible script is inserted, wherein the preset compatible script can be implemented in the following manner:
and inserting the preset compatible script into a response position of the form input control in the form of an external link, wherein the external link is used for downloading the compatible script from the preset server by the client.
The external link of the compatible script is a URL address through which the client can download the preset compatible script from the preset server. The URL, i.e. Uniform Resource Locator, is a compact representation of the location and access method of the Resource obtained from the internet, and is the address of the standard Resource on the internet. For example, the URL may be expressed as https:// mmm.mnnd.com/html 5 shiv/3.7.3/jianrong.js. Js represents the file name of the preset compatible script. When the browser resolves to this URL, the client will download the jiarong. The preset server is a server for providing preset compatible script downloading.
In particular, at the response location of the form input control, the response function of the form input control may be annotated to mask the response function, such as using the annotator "< | of HTML! - - - - >; a return statement may also be added at the top of the body of the response function to return an empty set, representing that the response function does nothing. Meanwhile, the external link of the preset compatible script is inserted into the response position of the form input control, such as https:// mmm.mnnd.com/html 5 shiv/3.7.3/jianrong.js.
In this embodiment, the inserted preset compatible script is not local at the client, but stored in the preset server, and is introduced to the response position of the form input control through the URL, so that when the browser parses the URL address, the client downloads the preset compatible script from the preset server. Because the preset compatible script is stored in the preset server, unified management and editing are facilitated, the workload of the client is reduced, and the execution speed is increased.
Further, in an embodiment, as shown in fig. 4, after step S2 and before step S4, that is, after the step of detecting a form tag in an HTML page in a current browser and acquiring a response position of a form input control corresponding to the form tag if the browser version number is lower than a preset version number threshold, and before the step of receiving a form operation message transmitted from a compatible script, saving a sequence number of a record in the form corresponding to the form tag, and acquiring a form operation type from the form operation message, the browser form compatibility method further includes the following steps:
s7: and inserting a preset click event forbidden script at the head of a main body label of the HTML page, and referring to an external link of the JavaScript library, wherein the preset click event forbidden script is used for shielding a response function of the form input control.
The body tag is a body tag, and the body tag is used for representing a page body part in an HTML page, and one HTML page must have one body tag. The browser parses the tags in the HTML from top to bottom, and since the position of the body tag is only after the HTML tag and the head tag and is the tag that is most preferentially parsed by the browser, the preset click event disable script inserted in the head of the body tag can be executed first.
The preset click event disable script is a JavaScript script that masks the response function of the form input control. For example, all mouse click events in the HTML page can be masked by JavaScript function document.
The JavaScript library, i.e., the JavaScript framework, is mostly an open-source software library provided by a third party and based on the JavaScript language. Common JavaScript libraries include jQuery, Prototype, MooTools, etc.
The external link of the JavaScript library is represented by a URL, for example, the external link of jQuery can be represented by http:// ajax.
Specifically, a preset JavaScript script disabled by a click event may be inserted into a head of a body tag of the HTML page to shield a response function of the form input control, and at the same time, an external link of the jQuery library may be added after the JavaScript script disabled by the click event, that is, a script tag is added into the body tag, for example, the following steps may be performed:
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
s8: and inserting a preset compatible script at the response position of the form input control, wherein the preset compatible script consists of functions of a JavaScript library.
The function of the JavaScript library is an API encapsulated based on the JavaScript library.
For example, if a function of a mouse click event in an HTML page can be expressed as document.getelementsbytagname.onclick (); and the statement of the jQuery library that realizes the same function is $ ("button"). click (function ()).
Specifically, at the response position of the form input control, the inserted preset compatible script may be a function name, and the function body of the function may be defined at other positions in the HTML and is composed of functions of the JavaScript library.
In this embodiment, a click event disabling script is inserted into the head of a main body tag of an HTML page, so that the script can be executed preferentially, and the execution of a response function of an original form input control is disabled; and meanwhile, an external link of the JavaScript library is inserted, and the preset compatible script is composed of functions of the JavaScript library.
Further, in an embodiment, for step S3, namely, the response position of the form input control, shielding the response function of the form input control, and inserting a preset compatible script, specifically, the method may include:
and shielding the response function of the form input control at the response position of the form input control, and inserting a preset compatible script at the bottom of a main body label of the HTML page.
The body tag is the tag on the outermost layer of the HTML page, except for the HTML tag and the head tag. Tags in an HTML page are all present in pairs, e.g., HTML tags include < HTML > and </HTML >, body tags include < body > and </body >, and so on. Wherein, HTML represents the beginning of HTML file, HTML represents the end of HTML file; < body > represents the beginning of the body segment, and </body > represents the end of the body segment. The bottom of the body tag is the position between and before body.
In particular, at the response location of the form input control, the response function of the form input control may be annotated to mask the response function, such as using the annotator "< | of HTML! - - - - >; a return statement may also be added at the top of the body of the response function to return an empty set, representing that the response function does nothing. Meanwhile, a preset compatible script is inserted between the body and at a position before the body.
In this embodiment, the preset compatible script is inserted into the bottom of the body tag of the HTML page, that is, into the position between the body and the position before the body, so that the parser of the browser can execute the compatible script after downloading all the elements in the HTML page, the downloading action of the browser is not blocked, the downloading speed is increased, and the phenomenon that the downloading action of other elements in the HTML page is blocked when the browser executes the JavaScript script, which causes the downloading speed of the browser page to become slow, and affects the user experience is avoided.
Further, in an embodiment, in step S1, detecting version information of the current browser to obtain a browser version number may specifically include:
and inserting a preset detection script at the head of the head label of the HTML page, wherein the preset detection script is used for detecting the version information of the current browser to obtain the version number of the browser.
The header tag, the head tag, represents the header in the HTML page that is defined in the header of the HTML page, and the elements in the head tag may reference scripts, instruct the browser where to find the style sheet, provide meta information, and so forth. The elements in the head tag are downloaded and parsed first by the browser.
The preset detection script is a JavaScript script used for detecting the version information of the current browser. The action of detecting the browser version is preferably placed at the front in the HTML page, i.e. may be at the head of the head tag of the HTML page, so that the preset detection script can be preferentially executed by the browser.
Specifically, a tag for presetting a detection script, such as < script type > < text/JavaScript > </script > may be inserted between the < head > tag and the </head > tag and behind the < head > tag, wherein the script tag is a specific JavaScript statement of the detection script.
In this embodiment, the preset detection script for detecting the version information of the current browser and obtaining the browser version number is inserted into the head of the head tag of the HTML page, so that the preset detection script can be preferentially executed by the browser, a step of browser form compatibility can be skipped by a high-version browser higher than a preset version number threshold, and the speed of analyzing the HTML page by the high-version browser is increased, so that the operation of the high-version browser is not affected by the technical scheme of the present invention on the premise that a user does not know which version of the browser is used, and various versions of all browsers can be compatible.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
In one embodiment, a browser form compatible device is provided, which corresponds to the browser form compatible method in the above embodiments one to one. As shown in fig. 5, the browser form compatible apparatus includes a version detecting module 51, an objective function position obtaining module 52, an objective function replacing module 53, a form operation obtaining module 54, a newly added record module 55, and a deleted record module 56. The functional modules are explained in detail as follows:
the version detection module 51 is configured to detect version information of a current browser to obtain a browser version number;
a target function position obtaining module 52, configured to detect a form tag in an HTML page in a current browser if the browser version number is lower than a preset version number threshold, and obtain a response position of a form input control corresponding to the form tag;
the target function replacing module 53 is configured to shield a response function of the form input control at a response position of the form input control, and insert a preset compatible script;
a table operation obtaining module 54, configured to receive a table operation message sent from the compatible script, store a serial number of a record where a cursor is located in a table corresponding to the table tag, and obtain a table operation type from the table operation message;
a newly added record module 55, configured to, if the table operation type is a newly added operation, obtain a newly added record to be inserted, insert the newly added record into the record in which the cursor is located, increment a sequence number of the newly added record on the basis of the sequence number of the record in which the cursor is located, and add the number of the newly added records to the sequence number of each cell included in each record after the newly added record;
and a delete record module 56, configured to delete the record where the cursor is located if the table operation type is a delete operation, and subtract the number of records where the deleted cursor is located from the sequence number of each cell included in each record after the record where the cursor is located.
Further, the objective function replacing module 53 includes:
and the first target function replacing submodule is used for shielding the response function of the form input control at the response position of the form input control and inserting an external link compatible with the script, wherein the external link is used for downloading the compatible script from a preset server by the client.
Further, the browser form compatible apparatus further includes:
the shielding module is used for inserting a preset click event forbidden script into the head of a main body label of the HTML page and quoting an external link of the JavaScript library, wherein the preset click event forbidden script is used for shielding a response function of the form input control;
and the second target function replacement module is used for inserting a compatible script in the response position of the form input control, wherein the compatible script is composed of functions of a JavaScript library.
Further, the objective function replacing module 53 further includes:
and the response function replacing sub-module is used for shielding the response function of the compatible script form input control at the response position of the compatible script form input control and inserting the compatible script at the bottom of the main body label of the compatible script HTML page.
Further, the version detection module 51 includes:
and the version detection submodule is used for inserting a preset detection script into the head of the head label of the HTML page, wherein the preset detection script is used for detecting the version information of the current browser to obtain the version number of the browser.
For specific limitations of the browser form compatible device, reference may be made to the above limitations of the browser form compatible method, which are not described herein again. The various modules in the browser form compatible device described above may be implemented in whole or in part by software, hardware, and combinations thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a client, and its internal structure diagram may be as shown in fig. 6. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a browser form compatibility method.
In one embodiment, a computer device is provided, which includes a memory, a processor, and a computer program stored on the memory and executable on the processor, and the processor executes the computer program to implement the steps of the browser table compatibility method in the above embodiments, such as steps S1 to S6 shown in fig. 2. Alternatively, the processor, when executing the computer program, implements the functions of the respective modules/units of the browser form compatible device in the above-described embodiments, such as the functions of the modules 51 to 56 shown in fig. 5. To avoid repetition, further description is omitted here.
In an embodiment, a computer-readable storage medium is provided, on which a computer program is stored, which, when being executed by a processor, implements the browser form compatible method in the above-mentioned method embodiment, or which, when being executed by a processor, implements the functions of the respective modules/units in the browser form compatible apparatus in the above-mentioned apparatus embodiment. To avoid repetition, further description is omitted here.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present invention, and are intended to be included within the scope of the present invention.

Claims (10)

1. A browser form compatibility method, the browser form compatibility method comprising:
detecting version information of a current browser to obtain a browser version number;
if the browser version number is lower than a preset version number threshold value, detecting a form tag in an HTML page in the current browser, and acquiring a response position of a form input control corresponding to the form tag;
shielding a response function of the form input control at a response position of the form input control, and inserting a preset compatible script;
masking the response function of the form input control at the response position of the form input control, comprising:
inserting a preset click event forbidden script into the head of a main body label of the HTML page, and referring to an external link of a JavaScript library, wherein the preset click event forbidden script is used for shielding a response function of the form input control;
receiving a table operation message transmitted from the compatible script, storing a serial number of a record where a cursor is located in a table corresponding to the table tag, and acquiring a table operation type from the table operation message;
if the table operation type is a new adding operation, acquiring a new adding record to be inserted, inserting the new adding record into the record of the cursor, increasing the sequence number in an increasing mode on the basis of the sequence number of the record of the cursor to serve as the sequence number of the new adding record, and adding the sequence number of each cell included in each record after the new adding record to the number of the new adding record;
and if the table operation type is deleting operation, deleting the record where the cursor is located, and subtracting the number of the deleted records where the cursor is located from the sequence number of each cell contained in each record after the record where the cursor is located.
2. The browser form compatibility method of claim 1, wherein said masking the response function of the form input control at the response location of the form input control and inserting a preset compatibility script comprises:
and the preset compatible script is inserted into a response position of the form input control in the form of an external link, wherein the external link is used for downloading the compatible script from a preset server by a client.
3. The browser form compatibility method of claim 1, wherein said masking the response function of the form input control at the response location of the form input control and inserting a preset compatibility script comprises:
and inserting the compatible script at the response position of the form input control, wherein the compatible script is composed of functions of the JavaScript library.
4. The browser form compatibility method of claim 1, wherein said masking the response function of the form input control at the response location of the form input control and inserting a preset compatibility script comprises:
and shielding the response function of the form input control at the response position of the form input control, and inserting the preset compatible script at the bottom of the main body label of the HTML page.
5. The browser form compatibility method of claim 1, wherein said detecting version information of a current browser to obtain a browser version number comprises:
and inserting a preset detection script at the head of the head label of the HTML page, wherein the preset detection script is used for detecting the version information of the current browser to obtain the version number of the browser.
6. A browser form compatible apparatus, comprising:
the version detection module is used for detecting the version information of the current browser to obtain the version number of the browser;
the target function position obtaining module is used for detecting a table tag in an HTML page in the current browser and obtaining a response position of a table input control corresponding to the table tag if the browser version number is lower than a preset version number threshold;
the target function replacement module is used for shielding the response function of the form input control at the response position of the form input control and inserting a preset compatible script;
the table operation acquisition module is used for receiving the table operation message transmitted from the compatible script, storing the serial number of the record of the cursor in the table corresponding to the table label and acquiring the table operation type from the table operation message;
the newly added record module is used for acquiring a newly added record to be inserted if the table operation type is a newly added operation, inserting the newly added record into the record in which the cursor is positioned, increasing the sequence number in an increasing mode on the basis of the sequence number of the record in which the cursor is positioned to serve as the sequence number of the newly added record, and adding the sequence number of each cell contained in each record after the newly added record to the number of the newly added record;
and the record deleting module is used for deleting the record where the cursor is located if the table operation type is the deleting operation, and subtracting the number of the records where the cursor is located from the serial number of each cell contained in each record after the record where the cursor is located.
7. The browser form compatible device of claim 6, wherein the objective function replacement module comprises:
and the first target function replacing sub-module is used for shielding the response function of the form input control at the response position of the form input control and inserting the external link of the preset compatible script, wherein the external link is used for downloading the compatible script from a preset server by a client.
8. The browser form compatible device of claim 6, further comprising:
the shielding module is used for inserting a preset click event forbidden script into the head of the main body label of the HTML page and quoting an external link of a JavaScript library, wherein the preset click event forbidden script is used for shielding a response function of the form input control;
and the second target function replacement module is used for inserting the preset compatible script into the response position of the form input control, wherein the compatible script is composed of functions of the JavaScript library.
9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the browser form compatibility method according to any one of claims 1 to 5 when executing the computer program.
10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the browser form compatibility method according to any one of claims 1 to 5.
CN201811252693.8A 2018-10-25 2018-10-25 Browser table compatibility method and device, computer equipment and storage medium Active CN109542501B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811252693.8A CN109542501B (en) 2018-10-25 2018-10-25 Browser table compatibility method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811252693.8A CN109542501B (en) 2018-10-25 2018-10-25 Browser table compatibility method and device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN109542501A CN109542501A (en) 2019-03-29
CN109542501B true CN109542501B (en) 2022-04-15

Family

ID=65845517

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811252693.8A Active CN109542501B (en) 2018-10-25 2018-10-25 Browser table compatibility method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN109542501B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111539025B (en) * 2020-05-07 2021-02-26 北京五八信息技术有限公司 Page display method and device, electronic equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103853659A (en) * 2012-12-06 2014-06-11 阿里巴巴集团控股有限公司 Browser compatibility testing method and device
CN104375858A (en) * 2014-10-27 2015-02-25 深信服网络科技(深圳)有限公司 Method and device for multiple browser platforms to execute javascript
CN108388454A (en) * 2018-01-24 2018-08-10 广州市动景计算机科技有限公司 Dynamic provides the method, apparatus and terminal device of compatible JS content for script

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20010013043A1 (en) * 1998-03-12 2001-08-09 Richard J. Wagner System and method for determining browser package and version compatibility of a web document
US20090199083A1 (en) * 2008-01-17 2009-08-06 Can Sar Method of enabling the modification and annotation of a webpage from a web browser
US20150094150A1 (en) * 2013-09-30 2015-04-02 Zynga Inc. Operation of a browser-incompatible application within a browser
CN105630524B (en) * 2014-10-31 2019-04-12 广州市动景计算机科技有限公司 Web page text analytic method, device and mobile terminal
CN108595202A (en) * 2018-04-25 2018-09-28 北京知道创宇信息技术有限公司 Http request processing method and processing device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103853659A (en) * 2012-12-06 2014-06-11 阿里巴巴集团控股有限公司 Browser compatibility testing method and device
CN104375858A (en) * 2014-10-27 2015-02-25 深信服网络科技(深圳)有限公司 Method and device for multiple browser platforms to execute javascript
CN108388454A (en) * 2018-01-24 2018-08-10 广州市动景计算机科技有限公司 Dynamic provides the method, apparatus and terminal device of compatible JS content for script

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
js实现添加删除一行。每一行下面可以再添加一行。序号自动改变;salestina;《https://download.csdn.net/download/salestina/9616964?spm=1001.2101.3001.5697》;20160830;全文第1-8页 *
ltx06;(16条消息) 解决IE8以下不支持getElementsByClassName的方法;《https://blog.csdn.net/ltx06/article/details/53762953/》;20161220;全文第1页 *

Also Published As

Publication number Publication date
CN109542501A (en) 2019-03-29

Similar Documents

Publication Publication Date Title
US10699061B2 (en) Application page quick access
CN108304498B (en) Webpage data acquisition method and device, computer equipment and storage medium
EP3273362A1 (en) Webpage access method, apparatus, device and non-volatile computer storage medium
CN108804159B (en) Javascript module loading method and preprocessing method and device thereof, and computer equipment
CN106294648B (en) Processing method and device for page access path
CN110688598A (en) Service parameter acquisition method and device, computer equipment and storage medium
CN107918587B (en) Debugging method and system for application program
CN109542501B (en) Browser table compatibility method and device, computer equipment and storage medium
CN110321177B (en) Mobile application localized loading method and device and electronic equipment
CN109522500B (en) Webpage display method, device, terminal and storage medium
CN110704521A (en) Interface data access method and system
CN110647320A (en) Project framework construction method and device, computer equipment and storage medium
CN108885544B (en) Front-end page internationalized processing method, application server and computer-readable storage medium
CN107480117B (en) Recovery method and device for automatic page table single data
CN112800078A (en) Lightweight text labeling method, system, equipment and storage medium based on javascript
CN111859204A (en) Information publishing method, device, equipment and storage medium
CN108595697B (en) Webpage integration method, device and system
CN110955428A (en) Page display method and device, electronic equipment and medium
CN111367521A (en) Message sending method and device and message receiving method and device
CN110851346A (en) Method, device and equipment for detecting boundary problem of query statement and storage medium
CN111367595A (en) Data processing method, program running method, device and processing equipment
US11126410B2 (en) Method and apparatus for building pages, apparatus and non-volatile computer storage medium
CN111898336B (en) Bullet screen display method and device, computer equipment and storage medium
CN110413931B (en) Data loading method and device, computer equipment and storage medium
CN109144500B (en) Skin file processing method based on graphical programming and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant