CN103634358A - Browser adaption method and apparatus - Google Patents
Browser adaption method and apparatus Download PDFInfo
- Publication number
- CN103634358A CN103634358A CN201210308009.XA CN201210308009A CN103634358A CN 103634358 A CN103634358 A CN 103634358A CN 201210308009 A CN201210308009 A CN 201210308009A CN 103634358 A CN103634358 A CN 103634358A
- Authority
- CN
- China
- Prior art keywords
- browser
- adaptation processing
- file
- type
- processing file
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Abstract
The invention provides a browser adaption method and apparatus, wherein the method and the apparatus are applied to a web site. The method comprises the following steps: determining a type of a browser according to a hyper text transfer protocol (HTTP) request sent by the browser; selecting an adaption processing file corresponding to the type of the browser from a plurality of prestored adaption processing files; and loading the adaption processing file. According to the invention, a prestored adaption processing file can be loaded according to the demand, thereby avoiding strong coupling between the original procedure code and the adaption processing file.
Description
Technical field
The present invention relates to Internet technology, relate in particular to a kind of browser adaptation method and device.
Background technology
Conventionally, PC is initiated HTML (Hypertext Markup Language) (Hyper Text Transfer Protocol to Web website by browser, HTTP) request, Web website is returned to web page files according to the described request of receiving to described browser, described web page files is according to HTML (Hypertext Markup Language, HTML) text of writing, described text comprises various marker characters.Browser is explained the various marker characters in the pagefile of receiving is resolved according to default marker character, and shows the web page contents that parsing obtains.
Along with the development of Internet technology, the kind of browser constantly increases, and at present, browser mainly comprises IE, Firefox, Chrome, Safari, Opera etc.The default marker character of different browsers is explained and is had difference, to same marker character, may have different explanations, like this, the web page contents that the same web page document analysis that different browsers is sent Web website obtains may be different, and it is abnormal resolving the web page contents obtaining even sometimes.
For addressing the above problem, at present, Web website is close coupling browser adaptation code on original program code, makes Web website for different browsers, sends corresponding web page files, different with the web page contents of avoiding different browser resolves to obtain.But, along with the continuous increase of the kind of browser, more and more with the browser adaptation code of the original program code close coupling in Web website, not only cause program code to be difficult for maintenance and expansion, even affect the normal operation of original program code.
Summary of the invention
In view of this, main purpose of the present invention is to provide a kind of browser adaptation method and device, can load as required the adaptation processing file prestoring, and avoids original program code and the close coupling of adaptation processing file.
For achieving the above object, technical scheme of the present invention is achieved in that
The invention provides a kind of browser adaptation method, be applied to Web website, described method comprises:
The HTML (Hypertext Markup Language) of sending according to browser (HTTP) is asked, and determines the type of described browser;
From the some adaptation processing files that prestore, choose the adaptation processing file corresponding with the type of described browser;
Load described adaptation processing file.
Preferably, described adaptation processing file comprises: pattern file and script file, and wherein, described pattern file is comprised of CSS list (CSS) code, and described script file is comprised of JavaScript code.
Preferably, the described adaptation processing file of described loading, for,
Create and pattern file and/or script file corresponding associated pattern node and/or script node in described adaptation processing file, add described pattern node and/or script node to pagefile, and activate described pattern node and/or script node.
Preferably, the described HTTP sending according to browser asks, and determines the type of described browser, for,
User Agent attribute in the HTTP request of sending according to browser, determines the type of described browser.
Preferably, described from the some adaptation processing files that prestore, before choosing the adaptation processing file corresponding with the type of described browser, described method also comprises:
In some adaptation processing files that judgement prestores, whether store the adaptation processing file corresponding with the type of described browser, when storing adaptation processing file corresponding to type with described browser, carry out the operation of choosing the adaptation processing file corresponding with the type of described browser.
The invention provides a kind of browser adaptive device, be applied to Web website, described device comprises:
Browser type determining unit, for HTML (Hypertext Markup Language) (HTTP) request of sending according to browser, determines the type of described browser;
Adaptation processing file is chosen unit, for the some adaptation processing files from prestoring, chooses the adaptation processing file corresponding with the type of described browser;
Adaptation processing file loading unit, for loading described adaptation processing file.
Preferably, described adaptation processing file comprises: pattern file and script file, and wherein, described pattern file is comprised of CSS list (CSS) code, and described script file is comprised of JavaScript code.
Preferably, described adaptation processing file loading unit, specifically for creating and pattern file and/or script file corresponding associated pattern node and/or script node in described adaptation processing file, add described pattern node and/or script node to pagefile, and activate described pattern node and/or script node.
Preferably, browser type determining unit, specifically for the User Agent attribute in the HTTP request of sending according to browser, the type of fixed described browser.
Preferably, described device also comprises:
Judging unit, for judging the some adaptation processing files that prestore, whether store the adaptation processing file corresponding with the type of described browser, when storing adaptation processing file corresponding to type with described browser, notice adaptation processing file is chosen unit and is carried out the operation of choosing the adaptation processing file corresponding with the type of described browser.
As from the foregoing, technical scheme of the present invention comprises: the HTTP sending according to browser asks, and determines the type of described browser; From the some adaptation processing files that prestore, choose the adaptation processing file corresponding with the type of described browser; Load described adaptation processing file, thus, the present invention loads the adaptation processing file prestoring as required, avoids original program code and the close coupling of adaptation processing file, not only can make program code be easy to maintenance and expansion, and not affect the normal operation of original program code.
Accompanying drawing explanation
Fig. 1 is the flow chart of the first embodiment of browser adaptation method provided by the invention;
Fig. 2 is the structural representation of the embodiment of browser adaptive device provided by the invention;
Fig. 3 is the flow chart of the second embodiment for browser adaptation method provided by the invention.
Embodiment
Basic thought of the present invention is: the HTML (Hypertext Markup Language) of sending according to browser (HTTP) is asked, and determines the type of described browser; From the some adaptation processing files that prestore, choose the adaptation processing file corresponding with the type of described browser; Load described adaptation processing file.
The first embodiment of browser adaptation method provided by the invention is applied to Web website, and as shown in Figure 1, described method comprises:
Preferably, described adaptation processing file comprises: pattern file and script file, and wherein, described pattern file is comprised of CSS list (Cascading Style Sheets, CSS) code, and described script file is comprised of JavaScript code.
Preferably, described step 103 can be, create and pattern file and/or script file corresponding associated pattern node and/or script node in described adaptation processing file, add described pattern node and/or script node to pagefile, and activate described pattern node and/or script node.
Preferably, described step 101 can be, the User Agent attribute in described HTTP request of sending according to browser is determined the type of described browser.
Preferably, before described step 102, described method can also comprise: in some adaptation processing files that judgement prestores, whether store the adaptation processing file corresponding with the type of described browser, when storing adaptation processing file corresponding to type with described browser, carry out the operation of choosing the adaptation processing file corresponding with the type of described browser.
The embodiment of the browser adaptive device that the present invention also provides is applied to Web website, and as shown in Figure 2, described device comprises:
Browser type determining unit, for the HTTP request of sending according to browser, determines the type of described browser;
Adaptation processing file is chosen unit, for the some adaptation processing files from prestoring, chooses the adaptation processing file corresponding with the type of described browser;
Adaptation processing file loading unit, for loading described adaptation processing file.
Preferably, described adaptation processing file can comprise: pattern file and script file, and wherein, described pattern file is comprised of CSS code, and described script file is comprised of JavaScript code.
Preferably, described adaptation processing file loading unit, can be specifically for creating and pattern file and/or script file corresponding associated pattern node and/or script node in described adaptation processing file, add described pattern node and/or script node to pagefile, and activate described pattern node and/or script node.
Preferably, browser type determining unit, can, specifically for the User Agent attribute in the HTTP request of sending according to browser, determine the type of described browser.
Preferably, described device can also comprise: judging unit, for judging the some adaptation processing files that prestore, whether store the adaptation processing file corresponding with the type of described browser, when storing adaptation processing file corresponding to type with described browser, notice adaptation processing file is chosen unit and is carried out the operation of choosing the adaptation processing file corresponding with the type of described browser.
Below the second embodiment of browser adaptation method provided by the invention is introduced, as shown in Figure 3, described method comprises:
The HTTP that send according to browser step 301, Web website asks, and determines the type of described browser;
Concrete, the User Agent attribute in the HTTP request that described Web sends according to browser website, determines the type of described browser.
In some adaptation processing files that the judgement of step 303, Web website prestores, whether store the adaptation processing file corresponding with the type of described browser, when storing adaptation processing file corresponding to type with described browser, enter step 304; When there is no the storage adaptation processing file corresponding with the type of described browser, finish this flow process;
Concrete, can be by initiating asynchronous JavaScript and extend markup language (Asynchronous JavaScript and Extensible Markup Language, AJAX) request, the mode of the filename of adaptation processing file under inquiry adaptation processing file directory, judgement is pre-stored in the some adaptation processing files under adaptation processing file directory, whether stores the adaptation processing file corresponding with the type of described browser;
Described adaptation processing file comprises: pattern file and script file, and wherein, described pattern file is comprised of CSS code, and described script file is comprised of JavaScript code, and described adaptation processing file can be according to the name nominating of its adaptive browser;
For example, the adaptation processing file " Firefox " corresponding with Firefox browser comprises pattern file Firefox.css and script file Firefox.js, the adaptation processing file " Chrome " corresponding with Chrome browser comprises pattern file Chrome.css and script file Chrome.js, corresponding to the adaptation processing file of each browser, is all stored under unified adaptation processing file directory.
Corresponding adaptation processing file, from the some adaptation processing files that prestore, is chosen in step 304, Web website;
Concrete, create and pattern file and/or script file corresponding associated pattern node and/or script node in the adaptation processing file of choosing, add described pattern node and/or script node to pagefile, and activate described pattern node and/or script node, can complete the loading of described adaptation processing file;
In practice, after loading original program code, load described adaptation processing file.
To sum up, the present invention can avoid original program code and the close coupling of adaptation processing file, like this, just can only under adaptation processing file directory, increase as required new adaptation processing file, also can only to existing adaptation processing file under adaptation processing file directory, modify, can also only delete existing adaptation processing file under adaptation processing file directory, realize thus in the situation that not affecting original program code, adaptation processing file is expanded and safeguarded.
The above, be only preferred embodiment of the present invention, is not intended to limit protection scope of the present invention.
Claims (10)
1. a browser adaptation method, is applied to Web website, it is characterized in that, described method comprises:
The HTML (Hypertext Markup Language) of sending according to browser (HTTP) is asked, and determines the type of described browser;
From the some adaptation processing files that prestore, choose the adaptation processing file corresponding with the type of described browser;
Load described adaptation processing file.
2. method according to claim 1, it is characterized in that, described adaptation processing file comprises: pattern file and script file, wherein, described pattern file is comprised of CSS list (CSS) code, and described script file is comprised of JavaScript code.
3. method according to claim 2, is characterized in that, the described adaptation processing file of described loading, for,
Create and pattern file and/or script file corresponding associated pattern node and/or script node in described adaptation processing file, add described pattern node and/or script node to pagefile, and activate described pattern node and/or script node.
4. method according to claim 1, is characterized in that, the described HTTP sending according to browser asks, and determines the type of described browser, for,
User Agent attribute in the HTTP request of sending according to browser, determines the type of described browser.
5. method according to claim 1, is characterized in that, described from the some adaptation processing files that prestore, before choosing the adaptation processing file corresponding with the type of described browser, described method also comprises:
In some adaptation processing files that judgement prestores, whether store the adaptation processing file corresponding with the type of described browser, when storing adaptation processing file corresponding to type with described browser, carry out the operation of choosing the adaptation processing file corresponding with the type of described browser.
6. a browser adaptive device, is applied to Web website, it is characterized in that, described device comprises:
Browser type determining unit, for HTML (Hypertext Markup Language) (HTTP) request of sending according to browser, determines the type of described browser;
Adaptation processing file is chosen unit, for the some adaptation processing files from prestoring, chooses the adaptation processing file corresponding with the type of described browser;
Adaptation processing file loading unit, for loading described adaptation processing file.
7. device according to claim 6, it is characterized in that, described adaptation processing file comprises: pattern file and script file, wherein, described pattern file is comprised of CSS list (CSS) code, and described script file is comprised of JavaScript code.
8. device according to claim 6, it is characterized in that, described adaptation processing file loading unit, specifically for creating and pattern file and/or script file corresponding associated pattern node and/or script node in described adaptation processing file, add described pattern node and/or script node to pagefile, and activate described pattern node and/or script node.
9. device according to claim 6, is characterized in that, browser type determining unit, specifically for the User Agent attribute in the HTTP request of sending according to browser, the type of fixed described browser.
10. device according to claim 6, is characterized in that, described device also comprises:
Judging unit, for judging the some adaptation processing files that prestore, whether store the adaptation processing file corresponding with the type of described browser, when storing adaptation processing file corresponding to type with described browser, notice adaptation processing file is chosen unit and is carried out the operation of choosing the adaptation processing file corresponding with the type of described browser.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201210308009.XA CN103634358A (en) | 2012-08-27 | 2012-08-27 | Browser adaption method and apparatus |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201210308009.XA CN103634358A (en) | 2012-08-27 | 2012-08-27 | Browser adaption method and apparatus |
Publications (1)
Publication Number | Publication Date |
---|---|
CN103634358A true CN103634358A (en) | 2014-03-12 |
Family
ID=50214980
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201210308009.XA Pending CN103634358A (en) | 2012-08-27 | 2012-08-27 | Browser adaption method and apparatus |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN103634358A (en) |
Cited By (14)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103942291A (en) * | 2014-04-11 | 2014-07-23 | 北京金山网络科技有限公司 | Method and device for displaying information on browser interface |
CN106547806A (en) * | 2015-09-23 | 2017-03-29 | 阿里巴巴集团控股有限公司 | Page loading method and device |
CN106599306A (en) * | 2016-12-29 | 2017-04-26 | 重庆南华中天信息技术有限公司 | Compatible display method of CSS style in network page |
CN106649820A (en) * | 2016-12-29 | 2017-05-10 | 重庆南华中天信息技术有限公司 | WEB server |
CN106648686A (en) * | 2016-12-29 | 2017-05-10 | 重庆南华中天信息技术有限公司 | CSS (Cascading Style Sheets) resource request processing device for WEB front end |
CN106648687A (en) * | 2016-12-29 | 2017-05-10 | 重庆南华中天信息技术有限公司 | Electronic device |
CN106682191A (en) * | 2016-12-29 | 2017-05-17 | 重庆南华中天信息技术有限公司 | Method for displaying CSS resource at front end |
CN106682181A (en) * | 2016-12-29 | 2017-05-17 | 重庆南华中天信息技术有限公司 | WEB front end CSS resource request processing method |
CN107066496A (en) * | 2016-12-29 | 2017-08-18 | 重庆南华中天信息技术有限公司 | A kind of page access method of compatible different browsers and terminal device |
CN107528714A (en) * | 2016-06-22 | 2017-12-29 | 中兴通讯股份有限公司 | script processing method, device, system and router |
CN108090069A (en) * | 2016-11-22 | 2018-05-29 | 北京神州泰岳软件股份有限公司 | A kind of method and apparatus for showing web page resources in a browser |
CN108388454A (en) * | 2018-01-24 | 2018-08-10 | 广州市动景计算机科技有限公司 | Dynamic provides the method, apparatus and terminal device of compatible JS content for script |
CN110083383A (en) * | 2019-03-18 | 2019-08-02 | 平安普惠企业管理有限公司 | Browser style compatibility method, device, computer equipment and storage medium |
CN115470127A (en) * | 2022-09-06 | 2022-12-13 | 北京海泰方圆科技股份有限公司 | Page compatibility processing method and device, computer equipment and storage medium |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20070220480A1 (en) * | 2006-03-17 | 2007-09-20 | Microsoft Corporation | Dynamic generation of cascading style sheets |
CN101178717A (en) * | 2007-12-05 | 2008-05-14 | 优视动景(北京)技术服务有限公司 | Method for adaptation processing web page and web page adaptation device |
CN101615121A (en) * | 2009-07-22 | 2009-12-30 | 福州星网视易信息系统有限公司 | The style editor of BS platform information delivery system |
CN101895582A (en) * | 2010-07-15 | 2010-11-24 | 北京邮电大学 | SIP soft terminal supporting WEB service and multiple browsers and working method thereof |
CN102637135A (en) * | 2011-02-09 | 2012-08-15 | 北京千橡网景科技发展有限公司 | Method and device for compiling CSS (cascading style sheet) |
-
2012
- 2012-08-27 CN CN201210308009.XA patent/CN103634358A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20070220480A1 (en) * | 2006-03-17 | 2007-09-20 | Microsoft Corporation | Dynamic generation of cascading style sheets |
CN101178717A (en) * | 2007-12-05 | 2008-05-14 | 优视动景(北京)技术服务有限公司 | Method for adaptation processing web page and web page adaptation device |
CN101615121A (en) * | 2009-07-22 | 2009-12-30 | 福州星网视易信息系统有限公司 | The style editor of BS platform information delivery system |
CN101895582A (en) * | 2010-07-15 | 2010-11-24 | 北京邮电大学 | SIP soft terminal supporting WEB service and multiple browsers and working method thereof |
CN102637135A (en) * | 2011-02-09 | 2012-08-15 | 北京千橡网景科技发展有限公司 | Method and device for compiling CSS (cascading style sheet) |
Non-Patent Citations (1)
Title |
---|
黎亚红等: ""CSS在不同浏览器中的兼容性问题浅析"", 《岳阳职业技术学院学报》 * |
Cited By (17)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103942291A (en) * | 2014-04-11 | 2014-07-23 | 北京金山网络科技有限公司 | Method and device for displaying information on browser interface |
CN106547806A (en) * | 2015-09-23 | 2017-03-29 | 阿里巴巴集团控股有限公司 | Page loading method and device |
CN106547806B (en) * | 2015-09-23 | 2020-12-18 | 阿里巴巴集团控股有限公司 | Page loading method and device |
CN107528714A (en) * | 2016-06-22 | 2017-12-29 | 中兴通讯股份有限公司 | script processing method, device, system and router |
CN108090069A (en) * | 2016-11-22 | 2018-05-29 | 北京神州泰岳软件股份有限公司 | A kind of method and apparatus for showing web page resources in a browser |
CN107066496A (en) * | 2016-12-29 | 2017-08-18 | 重庆南华中天信息技术有限公司 | A kind of page access method of compatible different browsers and terminal device |
CN106682191A (en) * | 2016-12-29 | 2017-05-17 | 重庆南华中天信息技术有限公司 | Method for displaying CSS resource at front end |
CN106682181A (en) * | 2016-12-29 | 2017-05-17 | 重庆南华中天信息技术有限公司 | WEB front end CSS resource request processing method |
CN106648687A (en) * | 2016-12-29 | 2017-05-10 | 重庆南华中天信息技术有限公司 | Electronic device |
CN106648686A (en) * | 2016-12-29 | 2017-05-10 | 重庆南华中天信息技术有限公司 | CSS (Cascading Style Sheets) resource request processing device for WEB front end |
CN106649820A (en) * | 2016-12-29 | 2017-05-10 | 重庆南华中天信息技术有限公司 | WEB server |
CN106599306A (en) * | 2016-12-29 | 2017-04-26 | 重庆南华中天信息技术有限公司 | Compatible display method of CSS style in network page |
CN108388454A (en) * | 2018-01-24 | 2018-08-10 | 广州市动景计算机科技有限公司 | Dynamic provides the method, apparatus and terminal device of compatible JS content for script |
CN108388454B (en) * | 2018-01-24 | 2021-08-20 | 阿里巴巴(中国)有限公司 | Method and device for dynamically providing JS (JavaScript) compatible script content and terminal equipment |
CN110083383A (en) * | 2019-03-18 | 2019-08-02 | 平安普惠企业管理有限公司 | Browser style compatibility method, device, computer equipment and storage medium |
CN115470127A (en) * | 2022-09-06 | 2022-12-13 | 北京海泰方圆科技股份有限公司 | Page compatibility processing method and device, computer equipment and storage medium |
CN115470127B (en) * | 2022-09-06 | 2023-08-15 | 北京海泰方圆科技股份有限公司 | Page compatibility processing method, device, computer equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN103634358A (en) | Browser adaption method and apparatus | |
CN104765622B (en) | Page resource loading method and device | |
EP2916243B1 (en) | Method, apparatus, server and system for implementing web application | |
CA2742059C (en) | Method and system for automated analysis and transformation of web pages | |
CN102737116B (en) | A kind of web page resources store method and device | |
CN103778365B (en) | Webpage hidden content detecting method and device | |
CN105095280A (en) | Caching method and apparatus for browser | |
CN102109989A (en) | Method, device and system for controlling browser cache | |
CN103294700A (en) | Cross-browser data local storage method and device | |
CN104808920A (en) | Focal point control method and focal point control device | |
CN103577603A (en) | Webpage loading method, device and system | |
WO2007107100A1 (en) | Method for accessing a parent page while browsing web pages | |
CN104601691A (en) | Method and system for increasing loading speed of Web site resource | |
CN105528369B (en) | Webpage code-transferring method, device and server | |
CN102981845B (en) | Browser carries out method and the device of page elements process | |
JP5488349B2 (en) | Relay device, relay method, and relay program | |
CN104915454A (en) | File preview system and method | |
CN104361067A (en) | Method and system for intelligent loading of browser webpage information | |
CN105335419A (en) | Webpage picture loading method and apparatus | |
CN103440143A (en) | System and method for upgrading mobile web application | |
CN105653678A (en) | Data chart subscription method and data chart subscription system | |
CN110704721A (en) | Client data processing method and device, terminal equipment and readable storage medium | |
CN102004729A (en) | Method and system for showing website webpage and website server | |
EP2998885A1 (en) | Method and device for information search | |
JP2010170453A (en) | Static web site construction method, static web site construction service providing method, dynamic/static conversion processor, and dynamic/static conversion processing program |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
EXSB | Decision made by sipo to initiate substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20140312 |
|
RJ01 | Rejection of invention patent application after publication |