Background technology
When the exploitation webpage, often all needing to rely on many personnel with professional knowledge and technology uses specific application software to carry out the editor of webpage on computers, after webpage is finished editor, webpage is uploaded to the server that website service is provided by the developer again.
Early stage webpage mainly is by HTML (Hypertext Markup Language) (HyperText Markup Language, HTML) grammer and script (script) are formed, the developer of webpage is the programmer mostly, but recently since style sheet (CSS) in webpage by a large amount of uses, therefore the developer of webpage has also increased and the complete visual designer inequality of programmer's professional domain except the programmer.Therefore, after the flow process of webpage development is normally made the webpage that has added the pattern grammer by visual designer at present, transfer to the programmer and in this webpage, write to browser and the program of carrying out on to server.
But, because in the process of webpage development, picture that webpage presented and the constantly adjustment of function that operation is provided, in addition, because the source code of webpage is not by same editor individual, but develop jointly by visual designer and programmer, therefore, when visual designer and programmer carry out again and again editor to the source code of webpage after, the source code of webpage can be more and more mixed and disorderly, under these circumstances, in case the complexity of picture that webpage will present or procedure code improves, it is more and more longer that the source code of webpage can become, to become increasingly complex, so, visual designer is difficult for revising the pattern grammer in the webpage, and the programmer also is difficult for revising scripts in web pages.In addition, because visual designer is unfamiliar with the script grammer usually, the programmer may be unfamiliar with the pattern grammer, so, when visual designer and programmer when revising the source code of webpage, often dare not delete unfamiliar script grammer or pattern grammer, so will cause easily to occur unnecessary script grammer or pattern grammer in the source code of webpage.
In sum, there has been the webpage source code easy care and occur the problem of unnecessary grammer easily not comprise HTML grammer, pattern grammer and script grammer simultaneously in prior art always since the midium or long term as can be known, therefore be necessary to propose improved technological means, solve this problem.
Summary of the invention
Because there is the webpage source code easy care and occur the problem of unnecessary grammer easily not comprise HTML grammer, pattern grammer and script grammer simultaneously in prior art, so the present invention discloses a kind of system and the method thereof of interactive element to carry out corresponding script of searching, wherein:
Search interactive element disclosed in this invention comprises: load module at least to carry out the system of corresponding script; Webpage insmods, and in order to be written into the target web that comprises at least one script function, does not comprise the script grammer in the label of target web; The webpage processing module, produce element in order to the script in the foundation target web and search unit and script executing unit, element is searched the unit and is used to search in the target web and comprises the element that is transfused to the interactive event that module triggers, and script executing unit is carried out the script function of corresponding interactive event and produced execution result in order to use element; Display module, in order to the display web page loaded target web that insmods, and in order to foundation execution result change display-object webpage.
Search interactive element disclosed in this invention is to carry out the system of corresponding script, and wherein, it is XML path language (XML Path Language, XPath) iterator and/or CSS iterator that element is searched the unit; Interactive event is that cursor moves to element, cursor shifts out element, cursor click element; Execution result is the show or hide of content of element and/or the change of attribute of an element.
Search interactive element disclosed in this invention is to carry out the system of corresponding script, and wherein, target web can also comprise the binding of the function shelves that write down script function, and the binding that webpage insmods more in order to foundation function shelves is written into the function shelves; Target web also can comprise the binding of the pattern shelves that write down employed pattern grammer, and webpage insmods more in order to the binding load style shelves of foundation pattern shelves.
Search interactive element disclosed in this invention is to carry out the method for corresponding script, and its step comprises at least: be written into the target web that comprises at least one script function, do not comprise the script grammer in the label of target web; The display-object webpage; Trigger the interactive event that element comprised in the target web; In target web, search element; Use element to carry out the script function corresponding, so as to producing execution result with interactive event; According to execution result change display-object webpage.
Search interactive element disclosed in this invention is to carry out the method for corresponding script, wherein, the step that is written into the target web that comprises script function can comprise according in the target web, the binding of record function shelves, be written into the step of the function shelves that comprise script function, or comprise according in the target web, write down the binding of pattern shelves, be written into the step of the pattern shelves that comprise the pattern grammer.
Search interactive element disclosed in this invention to be to carry out the method for corresponding script, wherein, is the content of show or hide element and/or shows attribute of an element by execution result changed according to the step of execution result change display-object webpage.
System and method for disclosed in this invention as above, and the difference between the prior art is that the present invention passes through addition element search unit in target web, after interactive event in target web is triggered, element is searched the unit can hunt out the element that comprises the interactive event that is triggered, make that the script grammer corresponding with interactive event is performed, so as to solution existing in prior technology problem, and can reach the technology effect that improves the efficient of developing/safeguard webpage and procedure code.
Embodiment
Below will cooperate graphic and embodiment describes feature of the present invention and embodiment in detail, content is enough to make any related art techniques person of haveing the knack of can fully understand the applied technological means of technical solution problem of the present invention easily and implements according to this, realizes the attainable effect of the present invention whereby.
The present invention is that adding can be after interactive event takes place in target web, automatically produce the script of the element (element) of interactive event in the searching target webpage, make and to change in the target web of the show state of element or content with script, can can separate with the script that is performed being used for the HTML grammer and pattern (CSS) grammer of display web page element specially, not write and do not need to be mixed in same place.That is to say, use the present invention, can not comprise any script grammer, make things convenient for visual designer to set up and the modifying target webpage so that be used for describing the label of each element of target web.Wherein, the script that the present invention carried is the set of the particular script grammer in the target web, can be formed by a plurality of script grammers, one or more script function or by one or more script grammers and one or more script function; The script function that the present invention carried then is made up of a plurality of script grammers, and it can reach specific function.
The interactive event that the present invention carried triggers the incident that element comprised in the target web for the user can operate cursor, for example cursor moves to that onmouseover () incident, the cursor that element triggers shifts out element onmouseout () incident, cursor is clicked element onclick () incident etc., but the present invention is not as limit.
Following elder generation illustrates System Operation of the present invention with the search interactive element that Fig. 1 the present invention is carried with the system architecture diagram of carrying out corresponding script.As shown in Figure 1, system applies of the present invention comprises wherein that webpage insmods 110, load module 120, webpage processing module 130 and display module 140 in the browser 100 of webpage.
Webpage insmods and 110 is responsible for being written into target web, wherein, is stored in the device of carrying out browser 100 by webpage 110 target webs that are written into that insmod, and generally speaking, the device of carrying out browser 100 can store target webs with Storage Media 400.
Webpage insmods 110 loaded target webs can be for writing HTML grammer and pattern grammer and script grammer the different piece at archives, in the case, HTML grammer in the target web and pattern grammer and script grammer have significantly and separate, and do not have the grammer that is mingled with.Target web also can be the archives of the binding of the binding that comprises HTML grammer with pattern title, function shelves and pattern shelves, webpage insmods 110 meetings after being written into target web, according to the binding of function shelves and the binding of pattern shelves, the pattern shelves of the function shelves of reading and recording script function and record pattern grammer to the Storage Media 400 are so as to finishing being written into of target web.
Load module 120 is responsible for providing the interactive event that a certain element comprised in the triggering target web.Generally speaking, the viewer that load module 120 provides target web operates cursor and moves and click, and moves to so as to triggering cursor that element, cursor shift out element, cursor is clicked interactive event such as element.
Webpage processing module 130 is responsible for producing element according to the script in the target web and is searched unit 132 and script executing unit 136, so as to the pairing script of interactive event in the target web can normally be carried out.
Element is searched unit 132 and is responsible for to search in the target web and comprises the element that is transfused to the interactive event that module 120 triggered.Element is searched the tree (tree) that unit 132 can be considered as target web data structure, and the node (node) of tree is the element in the target web, therefore, element is searched unit 132 can be XML path language (XML Path Language, XPath) element of use such as iterator and/or CSS iterator similar techniques.
Script executing unit 136 is responsible for using element to search the element execution script corresponding with the interactive event that is triggered that comprises the interactive event that is triggered that unit 132 is hunted out, be generally the form of function by script executing unit 136 execution scripts, but the present invention is not as limit.Wherein, if target web writes down the function shelves that comprise script function in the mode that links, then corresponding with the interactive event that is triggered script function can be recorded in the function shelves usually, but the present invention is not also as limit.
Script executing unit 136 can produce corresponding execution result after carrying out the script corresponding with the interactive event that is triggered.The execution result that script executing unit 136 is produced is the show or hide of the content of the one or more elements in the target web, and/or the change of the one or more attributes of an element (attribute) in the target web, but the present invention is not as limit.Wherein, the content element that is shown or is hidden for example "<div ...〉...</div ", "<li ...〉...</li " etc. element, but the present invention is not as limit; And the reformed element of attribute is including but not limited to picture element<img ..., link element<a ... the a of〉</〉 etc., reformed attribute can be picture path, coupling position, pattern grammer, data content etc., the present invention is not as limit.
Display module 140 is responsible for according to insmod each label in the 110 loaded target webs of webpage, each element of target web is presented in the browser 100, display module 140 also is responsible for according to the execution result that script executing unit produced, the show state of each element of change display-object webpage or the data content that is shown.
Then explain orally operation system of the present invention and method, and please refer to search interactive element that Fig. 2 the present invention put forward to carry out the method flow diagram of corresponding script with an embodiment.
When viewer's desire was used browser 100 browsing objective webpages 301, the viewer understood webpage in the operating browser 100 and insmods and 110 be written into target web 301 (step 210).In the present embodiment, hypothetical target webpage 301 is with concept development of the present invention, then target web 301 will be as shown in Figure 3A, at "<ul ...〉...</ul " "<li ...〉...</li ", "<div ...〉...</div〉", "<span ... ...</span〉", "<a href=... ...</a〉" etc. simple HTML grammer; and " class=" ... " ", " style=" ... " " wait the pattern grammer, and do not comprise any script grammer.Wherein, if target web 301 does not directly comprise pattern grammer/script grammer, but comprise the pattern shelves/script files that is attached to record pattern grammer/script grammer, the then webpage binding of the 110 pattern shelves/script files that can be comprised according to target web 301 that insmods, download pattern shelves/script files, so as to the grammer of the pattern in load style shelves/script files/script grammer.
Webpage insmod 110 be written into target web 301 (step 210) after, display module 140 can demonstrate target web 301 (step 220) in the user interface of browser 100, make load module 120 provide the user to operate the interactive event (step 230) that cursor triggers certain element in the target web 301.In the present embodiment, suppose that the interactive event that is triggered is that cursor moves on the element, when the object (object) that cursor is moved to representative on the user interface of element 330 at browser 100 by load module 120 as the user was gone up, the interactive event that element 330 is comprised was triggered.
Afterwards, the element in the webpage processing module 130 is searched unit 132 and can search the element (step 250) that comprises the interactive event that is triggered in target web 301.In the present invention, suppose that element searches unit 132 and be " XPath iterator ", then element is searched unit 132 can to search the element that comprises the interactive event that is triggered smoothly is element 330.
Element search unit 132 in webpage processing module 130 searches the element (step 250) that comprises the interactive event that is triggered in target web 301 after, script executing unit 136 in the webpage processing module 130 can be used by element and search the element execution script function corresponding with interactive event that unit 132 is hunted out, so as to producing execution result (step 260).In the present embodiment, suppose that script 302 in the script function corresponding with interactive event is shown in Fig. 3 B, then when element 330 when interactive event is triggered content for showing (visible), then script executing unit 136 can be carried out the script grammer 381 in the script 302, so, script executing unit 136 can produce and hide content that element 330 comprised and the execution result of changing the picture of a certain picture element in the target web 301; And if element 330 content when interactive event is triggered is hiding (hide), then script executing unit 136 can be carried out the script grammer 382 in the script 302, so, script executing unit 136 can produce content that display elements 330 are comprised and the execution result of changing the picture of a certain picture element in the target web 301.
Script executing unit 136 in webpage processing module 130 is carried out the script function corresponding with the interactive event that is triggered and after producing execution result (step 260), display module 140 can change the display-object webpages by execution results.In the present embodiment, just display module 140 can be hidden or the content of display element 330 according to the execution result that script executing unit 136 is produced, and to change the element that Shows Picture be corresponding picture.So, the script in the target web 301 promptly can separate with HTML grammer and pattern grammer to be write, and reaches same display effect.
In sum, difference between the present invention and the prior art is to have addition element search unit in target web as can be known, after interactive event in target web is triggered, element is searched the unit can hunt out the element that comprises the interactive event that is triggered, the technological means that the feasible script grammer corresponding with interactive event is performed, can solve the existing HTML grammer that comprises simultaneously of prior art by this technological means, the webpage source code of pattern grammer and script grammer is easy care and occur the problem of unnecessary grammer easily not, and then reaches the technology effect that improves the efficient of developing/safeguard webpage and procedure code.
Moreover, the element of searching when interactive event triggers of the present invention is to carry out the method for corresponding script, can be implemented in the combination of hardware, software or hardware and software, also can in computer system, realize or intersperse among the dispersing mode of the computer system of several interconnected and realize with different elements with centralized system.
Though embodiment disclosed in this invention is as above, be described content be not in order to direct qualification scope of patent protection of the present invention.Any persond having ordinary knowledge in the technical field of the present invention under the prerequisite that does not break away from spirit and scope disclosed in this invention, does a little change retouching to reaching of enforcement of the present invention in form on the details, all belong to scope of patent protection of the present invention.Scope of patent protection of the present invention, still must with appended claim the person of being defined be as the criterion.