Summary of the invention
The shortcoming of prior art in view of the above, the object of the present invention is to provide a kind of method and system dynamically generating menu bar based on flush type WEB server, complicated when generating or change menu bar for solving in prior art, the problem of easily makeing mistakes.
For achieving the above object and other relevant objects, the invention provides a kind of method dynamically generating menu bar based on flush type WEB server, for generating menu bar on a web browser, described method comprises: leave in specified file by the information being used for generating menu bar; Be menu bar predeterminated position to be generated in a browser and inside index.html file, add the function interface generating menu bar, browser sends menu bar to WEB server and generates request simultaneously; WEB server resolves the message of the request that described browser sends, and obtains the file name of described specified file and described index.html file; According to the function interface in described specified file and index.html file the information being used for generating menu bar added in described index.html file according to html language and form new index.html file; Described new index.html file is returned to browser by described WEB server, generates menu bar to make described browser according to described new index.html file at predeterminated position.
Preferably, the information for generating menu bar comprises menu bar title and URL link address.
Preferably, under serial ports pattern, revise the information for generating menu bar in described specified file.
Preferably, described specified file is the file of TXT form.
Preferably, described WEB server gets specified file by open function according to the file name of described specified file.
For achieving the above object, the present invention also provides a kind of browser of dynamic generation menu bar, and described browser comprises: menu bar file module, for leaving in specified file by the information being used for generating menu bar; Position is preset and is arranged module, for being menu bar predeterminated position to be generated in a browser; Function interface module, for adding the function interface generating menu bar inside index.html file; Request sending module, presets with described menu bar file module, described position and arranges that module and described function interface module are connected, and generates request for sending menu bar to WEB server; Menu bar generation module, is connected with described WEB server, generates menu bar according to the new index.html file that described WEB server returns at predeterminated position.
Preferably, the described information for generating menu bar comprises menu bar title and URL link address.
Preferably, under serial ports pattern, revise the information for generating menu bar in described specified file; Described specified file is the file of TXT form.
For achieving the above object, the present invention also provides a kind of WEB server of dynamic generation menu bar, and for generating menu bar on a web browser, described WEB server comprises: packet parsing module, for resolving the message of the request that described browser sends; Data obtaining module, is connected with described packet parsing module, for obtaining file name and the index.html file of specified file in described message; Message processing module, being connected with described data obtaining module, forming new index.html file for the information being used for generating menu bar being added in described index.html file according to html language according to the function interface in described specified file and described index.html file; Information returns module, is connected with described message processing module, for described new index.html file is returned to browser, generates menu bar to make described browser according to described new index.html file at predeterminated position.
For achieving the above object, the present invention also provides a kind of system dynamically generating menu bar based on flush type WEB server, and described system comprises browser as above and WEB server as above.
As mentioned above, a kind of method and system dynamically generating menu bar based on flush type WEB server of the present invention, have following beneficial effect:
1, in the present invention, menu bar and URL link are kept at external file, make menu bar independent, in change link or menu bar title, only need to change external file, allowing is not understand that very much the people of html language also can revise voluntarily, does not need to go to open corresponding html file at every turn, reduces error rate.
2, in the present invention, can when without the need to compiling and burning image file, only need can carry out random amendment and debugging by serial mode, also can go when communication facilities runs shape to change menu bar, eliminate and can only go to change menu bar by the method for burning image file at every turn, debugging is got up more convenient, substantially increases debugging efficiency.
3, in the present invention, resolve external file, complete in flush type WEB server inside, make the present invention have stronger versatility and practicality.
Embodiment
Below by way of specific instantiation, embodiments of the present invention are described, those skilled in the art the content disclosed by this instructions can understand other advantages of the present invention and effect easily.The present invention can also be implemented or be applied by embodiments different in addition, and the every details in this instructions also can based on different viewpoints and application, carries out various modification or change not deviating under spirit of the present invention.
The object of the present invention is to provide a kind of method and system dynamically generating menu bar based on flush type WEB server, complicated when generating or change menu bar for solving in prior art, the problem of easily makeing mistakes.To a kind of principle and embodiment dynamically generating the method and system of menu bar based on flush type WEB server of the present invention be elaborated below, make those skilled in the art not need creative work can understand a kind of method and system dynamically generating menu bar based on flush type WEB server of the present invention.
first embodiment
The present embodiment provides a kind of method dynamically generating menu bar based on flush type WEB server, the present embodiment solves traditional method of only removing to resolve generation menu bar by the page oneself itself, the function generating menu terminates in WEB server by the present embodiment, the page only needs to provide to deposit a menu bar position, at the root directory of correspondence, as added the TXT file of navigation bar title and chained address below TMP file, WEB server receives the request that browser sends over, when resolution data, check whether it is index.html, therefrom find the interface needing to resolve menu bar, content inside TXT file is added in html file according to the form of html language, and return to browser, such minimizing browser and web server interaction data amount, improve interactive efficiency, developer changes faster convenience.
As described in Figure 1, the described method dynamically generating menu bar based on flush type WEB server comprises the following steps.
Step S11, leaves in the information being used for generating menu bar in specified file.
Step S12, is menu bar predeterminated position to be generated and inside index.html file, adds the function interface generating menu bar, browser sends menu bar to WEB server and generates request simultaneously in a browser.
Step S13, WEB server resolves the message of the request that described browser sends, and obtains the file name of described specified file and described index.html file.
Step S14, to add to the information being used for generating menu bar in described index.html file according to html language according to the function interface in described specified file and index.html file and forms new index.html file.
Step S15, described new index.html file is returned to browser by described WEB server, generates menu bar to make described browser according to described new index.html file at predeterminated position.
Below step S11 and step S15 is described in detail.
In step s 11, the information being used for generating menu bar is left in specified file.Particularly, in the present embodiment, described specified file is the file of TXT form, and the information for generating menu bar comprises menu bar title and URL link address.
URL and URL(uniform resource locator), being a kind of expression succinctly of position to the resource that can obtain from internet and access method, is the address of standard resource on internet.Each file on internet has a unique URL, and the information that it comprises points out how the position of file and browser should process it.
In addition, in the present embodiment, the file of this TXT form is kept at the root directory of browser simultaneously, as under TMP catalogue, below TMP file, such as add the TXT file comprising navigation bar title and URL link address, the authority of TMP file is readable writing, and convenient temporarily going is changed.
In the present embodiment, menu bar and URL link are kept at specified file (external file), make menu bar independent, when changing URL link or menu bar title, only need to change external file, allowing is not understand that very much the people of html language also can revise voluntarily, does not need to go to open corresponding html file at every turn, reduces error rate.
In addition, under serial ports pattern, the information for generating menu bar in described specified file can be revised.With the inventive method can when without the need to compiling and burning image file, only need can carry out random amendment and debugging by serial mode, also can go when communication facilities runs shape to change menu bar, eliminate and can only go to change menu bar by the method for burning image file at every turn, debugging is got up more convenient, substantially increases debugging efficiency.
Step S12, is menu bar predeterminated position to be generated and inside index.html file, adds the function interface generating menu bar, browser sends menu bar to WEB server and generates request simultaneously in a browser.Wherein, index.html is homepage, and the homepage of most of website is all index.html.
Adopt CSS and HTML technology first that page layout is good, arrange menu bar at suitable position (i.e. predeterminated position).Wherein, CSS (CSS (cascading style sheet)) is the computerese that one is used for showing the file patterns such as HTML (standard generalized markup language) or XML (standard generalized markup language).CSS really can accomplish that webpage shows a kind of form design language be separated with content.For the performance of conventional HTML, CSS can carry out the accurate control of Pixel-level to the position typesetting of the object in webpage, support nearly all font size pattern, have the ability to web object and model pattern editor, and can preliminary interaction design be carried out, be at present based on the classic performance design language of textual presentation.CSS according to the understandability of different users, can simplify or optimize literary style, for all kinds of crowd, having stronger legibility.
Step S13, WEB server resolves the message of the request that described browser sends, and obtains the file name of described specified file and described index.html file.
Step S14, to add to the information being used for generating menu bar in described index.html file according to html language according to the function interface in described specified file and index.html file and forms new index.html file.
Step S15, described new index.html file is returned to browser by described WEB server, generates menu bar to make described browser according to described new index.html file at predeterminated position.
Particularly, in the present embodiment, described WEB server analytic message, extracts the file name of described specified file from URL, and described WEB server gets specified file by open function according to the file name of described specified file.Such as, open ("/www/menu.txt ", O_RDONLY), can know whether specified file exists.Visible, in the present embodiment, resolve external file, complete in flush type WEB server inside, make the present invention have stronger versatility and practicality.
For making those skilled in the art understand the method dynamically generating menu bar based on flush type WEB server of the present invention further, below to illustrate the implementation process of the inventive method.
First pad name and URL are added in menu.txt file (specified file) with the form of array:
Such as:
[quick guide, wizard_iframe.html];
[Storage sharing, media.html];
[Storage sharing is arranged, shares.html];
[user management, password.html];
[WAN is arranged, wanCfg.html];
[LAN is arranged, lanCfg.html];
[MAC clones, macClone.html];
[mode of operation, opmode.html];
Then inside index.html, add the function interface of the generation menu bar of needs, such as: "@interface function # ", send menu bar to WEB server and generate request.
Then inside flush type WEB server, resolve the message that browser sends over, acquisition request index.html, open function goes to judge whether menu.txt (specified file) exists, inside checking index.html file, whether function interface exists, all deposit in case at menu.txt sum functions interface, add upper corresponding menu according to html language form and create corresponding link, set up HTTP message, and returning to browser, described browser generates menu bar according to described new index.html file at predeterminated position.So, make to add menu bar independent from code.
second embodiment
For realizing the above-mentioned method dynamically generating menu bar based on flush type WEB server, the present embodiment correspondence provides a kind of system dynamically generating menu bar based on flush type WEB server, the present embodiment solves traditional method of only removing to resolve generation menu bar by the page oneself itself, the function generating menu terminates in WEB server by the present embodiment, the page only needs to provide to deposit a menu bar position, at the root directory of correspondence, as added the TXT file of navigation bar title and chained address below TMP file, WEB server receives the request that browser sends over, when resolution data, check whether it is index.html, therefrom find the interface needing to resolve menu bar, content inside TXT file is added in html file according to the form of html language, and return to browser, such minimizing browser and web server interaction data amount, improve interactive efficiency, developer changes faster convenience.
Particularly, as shown in Figure 2, the system 1 dynamically generating menu bar comprises the browser 11 and WEB server 12 that dynamically generate menu bar.
As shown in Figure 3, browser 11 comprises: menu bar file module 111, position are preset and arranged module 112, function interface module 113, request sending module 114 and menu bar generation module 115.
Menu bar file module 111 is for leaving in specified file by the information being used for generating menu bar; Particularly, in the present embodiment, described specified file is the file of TXT form, and the information for generating menu bar comprises menu bar title and URL link address.
URL and URL(uniform resource locator), being a kind of expression succinctly of position to the resource that can obtain from internet and access method, is the address of standard resource on internet.Each file on internet has a unique URL, and the information that it comprises points out how the position of file and browser 11 should process it.
In addition, in the present embodiment, the file of this TXT form is kept at the root directory of browser 11 simultaneously, as under TMP catalogue, below TMP file, such as add the TXT file comprising navigation bar title and URL link address, the authority of TMP file is readable writing, and convenient temporarily going is changed.
In the present embodiment, menu bar and URL link are kept at specified file (external file), make menu bar independent, when changing URL link or menu bar title, only need to change external file, allowing is not understand that very much the people of html language also can revise voluntarily, does not need to go to open corresponding html file at every turn, reduces error rate.
In addition, under serial ports pattern, the information for generating menu bar in described specified file can be revised.With the inventive method can when without the need to compiling and burning image file, only need can carry out random amendment and debugging by serial mode, also can go when communication facilities runs shape to change menu bar, eliminate and can only go to change menu bar by the method for burning image file at every turn, debugging is got up more convenient, substantially increases debugging efficiency.
Position is preset and is arranged that module 112 for being menu bar predeterminated position to be generated in browser 11; Wherein, index.html is homepage, and the homepage of most of website is all index.html.
Adopt CSS and HTML technology first that page layout is good, arrange menu bar at suitable position (i.e. predeterminated position).Wherein, CSS (CSS (cascading style sheet)) is the computerese that one is used for showing the file patterns such as HTML (standard generalized markup language) or XML (standard generalized markup language).CSS really can accomplish that webpage shows a kind of form design language be separated with content.For the performance of conventional HTML, CSS can carry out the accurate control of Pixel-level to the position typesetting of the object in webpage, support nearly all font size pattern, have the ability to web object and model pattern editor, and can preliminary interaction design be carried out, be at present based on the classic performance design language of textual presentation.CSS according to the understandability of different users, can simplify or optimize literary style, for all kinds of crowd, having stronger legibility.
Function interface module 113 for adding the function interface generating menu bar inside index.html file;
Request sending module 114 is preset with described menu bar file module 111, described position and is arranged that module 112 and described function interface module 113 are connected, and generates request for sending menu bar to WEB server 12.
Menu bar generation module 115 is connected with described WEB server 12, generates menu bar according to the new index.html file that described WEB server 12 returns at predeterminated position.
As shown in Figure 4, the WEB server 12 of the dynamic generation menu bar in the present embodiment, for generating menu bar on browser 11, described WEB server 12 comprises: packet parsing module 121, data obtaining module 122, message processing module 123 and information return module 124.
Packet parsing module 121 is for resolving the message of the request of described browser 11 transmission.
Data obtaining module 122 is connected with described packet parsing module 121, for obtaining file name and the index.html file of specified file in described message.
Message processing module 123 is connected with described data obtaining module 122, forms new index.html file for the information being used for generating menu bar being added in described index.html file according to html language according to the function interface in described specified file and described index.html file.
Information returns module 124 and is connected with described message processing module 123, for described new index.html file is returned to browser 11, generates menu bar to make described browser 11 according to described new index.html file at predeterminated position.
Particularly, in the present embodiment, described WEB server 12 analytic message, extracts the file name of described specified file from URL, and described WEB server 12 gets specified file by open function according to the file name of described specified file.Such as, open ("/www/menu.txt ", O_RDONLY), can know whether specified file exists.Visible, in the present embodiment, resolve external file, complete in flush type WEB server 12 inside, make the present invention have stronger versatility and practicality.
The system 1 dynamically generating menu bar based on flush type WEB server 12 of the present invention is understood further, below to illustrate the implementation process of the inventive method for making those skilled in the art.
First pad name and URL are added in menu.txt file (specified file) with the form of array:
Such as:
[quick guide, wizard_iframe.html];
[Storage sharing, media.html];
[Storage sharing is arranged, shares.html];
[user management, password.html];
[WAN is arranged, wanCfg.html];
[LAN is arranged, lanCfg.html];
[MAC clones, macClone.html];
[mode of operation, opmode.html];
Then inside index.html, add the function interface of the generation menu bar of needs, such as: "@interface function # ", send menu bar to WEB server 12 and generate request.
Then inside flush type WEB server 12, resolve the message that browser 11 sends over, acquisition request index.html, open function goes to judge whether menu.txt (specified file) exists, inside checking index.html file, whether function interface exists, all deposit in case at menu.txt sum functions interface, add upper corresponding menu according to html language form and create corresponding link, set up HTTP message, and returning to browser 11, described browser 11 generates menu bar according to described new index.html file at predeterminated position.So, make to add menu bar independent from code.
In sum, dynamically generate in the method and system of menu bar based on flush type WEB server of the present invention, menu bar and URL link are kept at external file, make menu bar independent, in change link or menu bar title, only need to change external file, allowing is not understand that very much the people of html language also can revise voluntarily, do not need to go to open corresponding html file at every turn, reduce error rate; The present invention can when without the need to compiling and burning image file, only need can carry out random amendment and debugging by serial mode, also can go when communication facilities runs shape to change menu bar, eliminate and can only go to change menu bar by the method for burning image file at every turn, debugging is got up more convenient, substantially increases debugging efficiency; In addition, in the present invention, resolve external file, complete in flush type WEB server inside, make the present invention have stronger versatility and practicality.So the present invention effectively overcomes various shortcoming of the prior art and tool high industrial utilization.
Above-described embodiment is illustrative principle of the present invention and effect thereof only, but not for limiting the present invention.Any person skilled in the art scholar all without prejudice under spirit of the present invention and category, can modify above-described embodiment or changes.Therefore, such as have in art usually know the knowledgeable do not depart from complete under disclosed spirit and technological thought all equivalence modify or change, must be contained by claim of the present invention.