CN103543991B - A kind of method and browser for extending browser function - Google Patents

A kind of method and browser for extending browser function Download PDF

Info

Publication number
CN103543991B
CN103543991B CN201210237542.1A CN201210237542A CN103543991B CN 103543991 B CN103543991 B CN 103543991B CN 201210237542 A CN201210237542 A CN 201210237542A CN 103543991 B CN103543991 B CN 103543991B
Authority
CN
China
Prior art keywords
script
protogenous
created
attribute
page
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
CN201210237542.1A
Other languages
Chinese (zh)
Other versions
CN103543991A (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.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology 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 Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN201210237542.1A priority Critical patent/CN103543991B/en
Publication of CN103543991A publication Critical patent/CN103543991A/en
Application granted granted Critical
Publication of CN103543991B publication Critical patent/CN103543991B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The present invention provides a kind of method and browser for extending browser function, wherein this method includes:A. the script engine module parsing page script of browser, determines non-protogenous example script to be created in the page script in resolving;B. mapping relations of the Scripting Agent module in preset plug-in description file create java class example, and create the non-protogenous example script to be created according to the java class example;C. it when the script engine module calls the non-protogenous example script created in resolving, triggers the Scripting Agent module and calls java class example corresponding with the non-protogenous example script created.By the above-mentioned means, a kind of new browser plug-in mechanism can be realized, available plug number is greatly increased.

Description

A kind of method and browser for extending browser function
【Technical field】
The present invention relates to browser plug-ins to realize technology, more particularly to a kind of method and browser for extending browser function System.
【Background technology】
Browser plug-in is the application being extended to the function of browser.Existing browser plug-in realizes technology(I.e. The technology of Function Extension is carried out to browser)Mainly include following three classes:ActiveX technologies based on IE platforms, can be across clear Look at device platform NPAPI technologies and the Applet technologies realized on the browser for supporting JAVA.These three are browsed below Device plug-in unit realizes that technology is introduced accordingly.
1st, ActiveX is the proprietary technology on the WINDOWS platform of Microsoft.It uses COM(Component Object Model, component object model)Technology so that software component(That is the primary control program of component and component)It in a network environment can be with It interacts.COM technologies are a kind of methods that binary code is shared across application and language, define different application in binary system The standard interacted in rank, due to standard as ActiveX plug-in units and browser satisfaction, ActiveX plug-in units are only It will be with DLL(Dynamic Link Library, dynamic link library)Form be registered to registration table, it is possible to for browser tune With.Specifically, the process of browser loading ActiveX plug-in units please refers to Fig.1 and Fig. 2.
When Fig. 1 uses ActiveX plug-in units for the prior art, webpage source file writes example schematic.It can be with from Fig. 1 Find out, to use ActiveX plug-in units, need to be identified using OBJECT labels in html document, in the attribute of the label In, also identify GUID of the ActiveX plug-in units in registration table(Globally Unique Identifier, the unique mark in the whole world Know symbol).Fig. 2 is the loading procedure schematic diagram of the ActiveX plug-in units of the prior art.As shown in Fig. 2, it is loaded first in browser During html page, DOM is carried out(DOM Document Object Model)Conversion finds OBJECT labels in this process, will be from registration table The middle corresponding ActiveX plug-in units of GUID searched as specified in the OBJECT tag attributes in Fig. 1, to obtain corresponding ActiveX The position of plug-in unit, according to the position, corresponding ActiveX plug-in units can be loaded into memory and run by browser, realize phase The function of answering.
2nd, NPAPI is a kind of browser plug-in technology that Netscape companies propose.It is the plug-in unit skill of similar ActiveX Art, but it defines the developing plug standard of a browser-cross, the browser plug-in for meeting NPAPI standards can be a variety of Browser(Such as Firefox, Chrome, Safari, Opera)It is upper called.Common FLASH players, Alipay safety Control is all the plug-in unit using NPAPI technological development.
It please refers to Fig.3, Fig. 3 is the schematic diagram of the loading procedure of the NPAPI plug-in units of the prior art.When browser starts, The file of the package types under default path is loaded, and initializes plug-in environment(Each plug-in unit is correspondingly registered to browser In), in initialization, according to the standard of NPAPI, plug-in unit and browser can call the function passes information that other side provides respectively, Browser obtains the information in plug-in unit simultaneously, will be in plug-in registration to browser.When the page loads, in the process of DOM parsings Middle to find label as shown in Figure 4, browser, which will determine that in registered plug-ins, whether there is and MimeType types one shown in Fig. 4 The plug-in unit of cause, if it is present the example of the plug-in unit is created, to provide the extension that corresponding function realizes browser function.When When the page is destroyed, the plug-in unit example created on the page before accordingly also can be destroyed, when browser is closed, will move out plug-in unit Environment.
3rd, Applet is the technology by the use of the applet that Java language is write as plug-in unit, these programs are directly embedded into It in the page, is explained and performed by Java-compliant browser, so as to fulfill the purpose of extension browser function.
Fig. 5 is please referred to, Fig. 5 is schematic diagram of the prior art using the page source file of Applet plug-in units.Correspond to the page Face, the loading procedure of Applet are as follows:Browser loading page finds Appplet labels when carrying out DOM parsings, then exists The path of Applet tag definitions(X)It is lower according to class name(Y)Corresponding applet classes are found, and using Java Virtual Machine to this Class explains execution, to realize the corresponding function of the Applet.
It is seen by the three of the above prior art, the problem is that:(1)Under the mode of ActiveX and NPAPI, exploitation is clear Device plug-in unit of looking at all needs to meet specific communication standard, this causes the difficulty of developing plug to increase, workable so as to affect Plug number;(2)Three of the above method is required to be marked with special label in page source file to be loaded, ability Realize the calling of corresponding plug-in unit;(3)Three of the above method is required for specifying display area for plug-in unit when loading browser plug-in (" width " and " height " attribute that can be under each method in corresponding source file label is found out);
【Invention content】
The technical problems to be solved by the invention are to provide a kind of method and browser for extending browser function, with It realizes a kind of new browser plug-in mechanism, to solve developing plug in the prior art and use complexity, and leads to available insert The defects of number of packages amount is few.
The present invention for solve technical problem and the technical solution adopted is that provide it is a kind of extend browser function method, packet It includes:A. the script engine module parsing page script of browser, determines to be created in the page script in resolving Non-protogenous example script, and the mark of the non-protogenous example script to be created is sent to the Scripting Agent mould of browser Block;B. mapping relations of the Scripting Agent module in preset plug-in description file create corresponding with the mark Java class example, and the non-protogenous example script to be created is created according to the java class example;C. when the script draws When holding up module the method for non-protogenous example script created is called in resolving, trigger the Scripting Agent module and call Call result is simultaneously back to described by the correlation method of java class example corresponding with the non-protogenous example script created Script engine module.
According to one of present invention preferred embodiment, the step of non-protogenous example script to be created in the page script is determined Suddenly it specifically includes:Judge that the reference referent in the page script whether there is in memory, if it is not, then determining that this draws It is non-protogenous example script to be created with referent;Alternatively, the key acted by characterizing establishment in the page script Word determines example script to be created, and judge the affiliated class of example script to be created whether in the page script quilt Definition, if it is not, then determining that the example script to be created is non-protogenous example script to be created.
According to one of present invention preferred embodiment, the attribute of the mapping relations includes:First attribute and the second attribute, Wherein described first attribute is described for describing the title of non-protogenous example script or the title of the affiliated class of non-protogenous example script Second attribute is used to describe the title of java class corresponding with first attribute.
According to one of present invention preferred embodiment, the attribute of the mapping relations further includes:Third attribute, wherein described The valid period of object that three attributes generate for description according to the mapping relations.
According to one of present invention preferred embodiment, the property value of the third attribute includes:Pin is loaded onto in a page Period effective page attribute values are ruined, down periods effective session attribute value is loaded onto in a browser or is taken with one Effective Domain Properties value during business device interaction.
It is specific the step of java class example described in the Scripting Agent module creation according to one of present invention preferred embodiment Including:The Scripting Agent module determines that the property value of the first attribute identifies the mapping to match pass with described in each mapping relations System, and create the example of java class specified by the property value of the second attribute in the mapping relations.
It is described to identify the name for including the non-protogenous example script to be created according to one of present invention preferred embodiment Claim, alternatively, the title of the affiliated class of non-protogenous example script to be created.
According to one of present invention preferred embodiment, the non-protogenous script to be created is created according to the java class example The step of example, specifically includes:Determine that the non-protogenous script to be created is real according to the attribute of the java class example and method The definition of example, and the non-protogenous example script to be created is created according to this definition.
According to one of present invention preferred embodiment, the method the step A take a step forward including:The Scripting Agent Module determines that third property value is the mapping relations of session attribute value in the plug-in description file, and creates the mapping relations and refer to Fixed java class example and non-protogenous example script corresponding with the java class example.
According to one of present invention preferred embodiment, the correlation method is to have with the method for the non-protogenous example script of calling There is the method for same names.
The present invention also provides a kind of browsers, and including script engine module and Scripting Agent module, feature exists In the script engine module includes:Resolution unit, for parsing page script;Detection unit, in the resolution unit Determine non-protogenous example script to be created in the page script in resolving, and by the non-protogenous script to be created The mark of example is sent to the Scripting Agent module of browser;The Scripting Agent module includes:Execution unit, first create list Member and the second creating unit;First creating unit creates for the mapping relations in preset plug-in description file Java class example corresponding with the mark;Second creating unit, for being treated according to java class example establishment The non-protogenous example script of establishment;The resolution unit is additionally operable to call the non-protogenous example script created in resolving Method when, execution unit operation is triggered, wherein the execution unit is for calling and the non-protogenous foot created Call result is simultaneously back to the resolution unit by the correlation method of the corresponding java class example of this example.
According to one of present invention preferred embodiment, the detection unit determines non-protogenous to be created in the page script The mode of example script specifically includes:The detection unit judges that the reference referent in the page script is in memory No presence, if it is not, then determining that the reference referent is non-protogenous example script to be created;Alternatively, the detection unit The keyword acted by characterizing establishment in the page script determines example script to be created, and judge described to be created Whether the affiliated class of example script is defined in the page script, if it is not, then determining that the example script to be created is Non-protogenous example script to be created.
According to one of present invention preferred embodiment, the attribute of the mapping relations includes:First attribute and the second attribute, Wherein described first attribute is described for describing the title of non-protogenous example script or the title of the affiliated class of non-protogenous example script Second attribute is used to describe the title of java class corresponding with first attribute.
According to one of present invention preferred embodiment, the attribute of the mapping relations further includes:Third attribute, wherein described The valid period of object that three attributes generate for description according to the mapping relations.
According to one of present invention preferred embodiment, the property value of the third attribute includes:Pin is loaded onto in a page Period effective page attribute values are ruined, down periods effective session attribute value is loaded onto in a browser or is taken with one Effective Domain Properties value during business device interaction.
According to one of present invention preferred embodiment, the mode that first creating unit creates the java class example is specific Including:First creating unit determines that the property value of the first attribute identifies the mapping to match pass with described in each mapping relations System, and create the example of java class specified by the property value of the second attribute in the mapping relations.
It is described to identify the name for including the non-protogenous example script to be created according to one of present invention preferred embodiment Claim, alternatively, the title of the affiliated class of non-protogenous example script to be created.
According to one of present invention preferred embodiment, it is real that second creating unit creates the non-protogenous script to be created The mode of example specifically includes:Second creating unit determines described to be created according to the attribute and method of the java class example Non-protogenous example script definition, and the non-protogenous example script to be created is created according to this definition.
According to one of present invention preferred embodiment, the Scripting Agent module further comprises:Pre-add carrier unit, for Before the resolution unit parsing page script, mapping of the third property value for session attribute value in the plug-in description file is determined Relationship, and create java class example and non-protogenous example script corresponding with the java class example that the mapping relations are specified.
According to one of present invention preferred embodiment, the correlation method is to have with the method for the non-protogenous example script of calling There is the method for same names.
As can be seen from the above technical solutions, by the method for the present invention, following technique effect can be obtained:(1)It can build The communication mechanism in script space to Java spaces is erected, does not need to specially develop again and meets the plug-in unit of certain communications protocol to carry out Browser extends, and is available with the existing java class for having realized various functions, to extend the function of browser, so as to make Obtaining largely already present java class can use as browser plug-in, considerably increase workable plug number.(2)With showing There is technology to compare, the present invention had not both needed to be labeled with special label in the source file of the page, it is not required that be plug-in unit Specified display area, so as to which the use of plug-in unit be allowed to become more flexible.
【Description of the drawings】
When Fig. 1 uses ActiveX plug-in units for the prior art, webpage source file writes example schematic;
Fig. 2 is the loading procedure schematic diagram of the ActiveX plug-in units of the prior art;
Fig. 3 is the loading procedure schematic diagram of the NPAPI plug-in units of the prior art;
When Fig. 4 uses NPAPI plug-in units for the prior art, webpage source file writes example schematic;
Fig. 5 is schematic diagram of the prior art using the page source file of Applet plug-in units;
Fig. 6 is the flow diagram of the embodiment of the method for present invention extension browser function;
Fig. 7 is the structural schematic block diagram of the embodiment of browser in the present invention.
【Specific embodiment】
To make the objectives, technical solutions, and advantages of the present invention clearer, it is right in the following with reference to the drawings and specific embodiments The present invention is described in detail.
It is carried out in script citing in this specification using JavaScript scripts, it should be appreciated that, present invention side Script in method should not be limited only to this.
In the present invention, browser includes script engine module and Scripting Agent module.Wherein script engine module is used It is interacted in script, and according to interaction scenario, completes the communication between Scripting Agent module.Scripting Agent module, for root According to the information that script engine transmits, relevant action is performed.The above process will be introduced by specific embodiment below.
Fig. 6 is please referred to, Fig. 6 is the flow diagram of the embodiment of the method for present invention extension browser function, such as Fig. 6 institutes Show, method of the invention mainly includes the following steps that:
The script engine module parsing page script of S1, browser, determine to be created in page script in resolving Non-protogenous example script, and the mark of non-protogenous example script to be created is sent to the Scripting Agent module of browser.
The mapping relations of S2, Scripting Agent module in preset plug-in description file create corresponding with above-mentioned mark Java class example, and above-mentioned non-protogenous example script to be created is created according to the java class example.
S3, when script engine module calls the method for non-protogenous example script created in resolving, triggering Scripting Agent module is called the correlation method of java class example corresponding with the non-protogenous example script created and is tied calling Fruit is back to script engine module.
Above-mentioned steps are specifically described below.
In step S1, for browser when loading a page, script engine module parses the script in the page, Non-protogenous example script to be created in the page is determined in resolving.Non-protogenous example script is referred to only through page foot Definition in this, the example script that can not be created.Specifically, it is determined that the step of non-protogenous example script to be created, includes:
Judge that the reference referent in page script whether there is in memory, if the reference referent is in memory In be not present, it is determined that the reference referent be non-protogenous example script to be created.
Please refer to code block 1:
<Script language=" Javascript ">
alert(ExtCalendar.now());(1)
</script>
It is not present in memory assuming that quoting " ExtCalendar " referent in code block 1, then it is assumed that " ExtCalendar " referent is non-protogenous example script to be created.
In addition, determine that the embodiment of non-protogenous example script to be created in page script further includes:Pass through page foot Keyword of characterization establishment action determines example script to be created, and whether judge the affiliated class of example script to be created in this It is defined in page script, if it is not, then determining that example script to be created is non-protogenous example script to be created.
Please refer to code block 2:
Pass through " new " keyword in code block 2(That is the keyword of characterization establishment action)Example script to be created " mailer ", if its affiliated class Mailer in page script without definition, then it is assumed that " mailer " be non-original to be created Raw example script.
In step S1, script engine module is after non-protogenous example script to be created is determined, by the non-original to be created Raw example script mark is sent to Scripting Agent module, and so in step s 2, Scripting Agent module can just be looked for according to the mark To corresponding mapping relations, so as to create corresponding java class example and non-protogenous example script according to corresponding mapping relations.
Specifically, in step S2, Scripting Agent module reads plug-in description file, with the non-original sended in step S1 The mark of raw example script searches matched mapping relations as keyword in plug-in description file.
Content in code block 1 and code block 2 enumerated supra is appreciated that the non-protogenous sent in step S1 The mark of example script, either the title of the non-protogenous example script(Such as " ExtCalendar " in code block 1), It can be the title of the affiliated class of non-protogenous example script(Such as " Mailer " in code block 2).It is corresponding, plug-in unit description The attribute of a mapping relations in file, includes the first attribute and the second attribute, wherein the first attribute is used to describe non-original The title of raw example script or the title of the affiliated class of non-protogenous example script, the second attribute are corresponding with the first attribute for describing The title of java class.
Code block 3 is please referred to, code block 3 is the signal code of the mapping relations in plug-in description file:
The first attribute description in the mapping relations of above-mentioned the second row of code title of the affiliated class of non-protogenous example script (class name), the second attribute description title of corresponding java class(java class);The mapping relations of three or four row In the first attribute description title of non-protogenous example script(instance name), second attribute description is corresponding The title of java class.
In step S2, Scripting Agent module creation java class corresponding with the mark of non-protogenous example script to be created is real The step of example, specifically includes:
Determine that the property value of the first attribute and the mark of non-protogenous example script to be created match in each mapping relations Mapping relations, and create the example of java class specified by the property value of the second attribute in the mapping relations.
Since the mark of non-protogenous example script to be created is either the title of the example can also be the example institute Belong to the title of class, in step S2 when determining matched mapping relations, it is only necessary to which the mark sended over using step S1 is each Matched and searched is carried out in the first property value of mapping relations.
Such as the non-protogenous example script that is sended in step S1 is identified as " Mailer ", the second of code block 3 The property value " Mailer " of the first attribute is matching in row mapping relations, then passes through this row mapping relations, it may be determined that corresponding Java class for " com.plugin.mailer ", utilize such class file, it is possible to create corresponding java class example.On The class file stated can be stored under default path, and a new attribute can also be added in mapping relations for characterizing The deposit position of java class file(It is not shown in code block 3)If it is being created in mapping relations comprising such a attribute When building corresponding java class, the position specified to the property value is gone to obtain class file to create corresponding java class example.
After java class example is created, the java class example can be packaged as non-protogenous by Scripting Agent module in step S2 Example script, that is, the non-protogenous example script to be created determined in preceding step S1 is created according to the java class example. By the step, Java spaces just establish interaction mechanism with script space, so as to be realized in subsequent step from foot The calling in this space is called to Java spaces.Specifically, it is to be created non-according to what is determined in java class example foundation step S1 The step of primary example script, includes:Non-protogenous example script to be created is determined according to the attribute of the java class example and method Definition, and the non-protogenous example script is created according to this definition.In the definition of non-protogenous example script to be created, determine The non-protogenous example script has the attribute and method identical with the corresponding java class example created, in this way, follow-up step Calling in rapid in script space is come up with regard to that can be properly mapped to the calling in Java spaces.Same alike result described herein and side Method, be it is substantially the same be not limited solely to that name is identical, if for example, in plug-in description file to the method for java class example and The correspondence of the method for non-protogenous example script is described, then should determine same procedure according to this description.Such as The java class example A created is gathered around there are one " read " method, it is assumed that has following two attribute in mapping relations:<……java_ m=read,instance_m=readme……>
So then it should be understood that non-protogenous example script to be created and the method name of the same procedure of A created should Should be readme rather than read.
As a preferred embodiment, the present invention does not describe the method and category of Java examples and non-protogenous example script Property between correspondence, but acquiescence mapped between the two with identical title.
According to foregoing description, it should be appreciated that is described in step s3 " calls the non-protogenous example script pair with having created The correlation method of java class example answered ", correlation method therein, there are java class examples and non-original in plug-in description file Can be the method determined in the correspondence when correspondence between the method for raw example script describes.As preferred Embodiment, due to the not correspondence between the method for java class example and non-protogenous example script in plug-in description file Be described, thus correlation method be exactly java class example, with call non-protogenous example script method have it is mutually of the same name The method of title.Such as the method for non-protogenous example script that script engine module is called is " now " method, then triggers Scripting Agent Module calls " now " method of corresponding java class example.
In step S3, since the reflex mechanism of Java causes the method for arbitrarily calling a java class example during operation to become May, thus it will be appreciated by those skilled in the art that in the range of, above-mentioned call-by mechanism is not difficult to realize, this specification to this not It repeats.
It can also be seen that third attribute can also be included in the attribute of mapping relations from code block 3(lifecycle), The valid period of object that wherein attribute generates for description according to the mapping relations.The property value of third attribute can be One page effective page attribute values during being loaded onto destruction are loaded onto down periods effective session category in a browser Property value or effective Domain Properties value during being interacted with a server.In the mapping relations of 3 second row of code block, third category Property value " page " represent be exactly page attribute values, in the mapping relations of the three or four row, third property value " session " expression It is exactly session attribute value.
Within the valid period of third attribute definition, the java class example and non-protogenous foot that are generated according to correspondence mappings relationship This example can always exist, such as the object of session attribute value(Java class example and non-protogenous example script)Once it creates, then Before browser is closed effectively, until browser is closed, ability is destroyed, and the object of page attribute values is closed in current page It will be destroyed when closing.
Since the object of session attribute value is unrelated with the life cycle of the page, can first be created before the page loads, with Directly invoked when the page loads, therefore, the present invention can also step S1 take a step forward including:
Scripting Agent module determines that third property value is the mapping relations of session attribute value in plug-in description file, and creates The java class example and non-protogenous example script corresponding with the java class example that the mapping relations are specified.
Fig. 7 is please referred to, Fig. 7 is the structural schematic block diagram of the embodiment of the browser in the present invention.As shown in fig. 7, The system includes:Script engine module and Scripting Agent module, wherein, script engine module includes:Resolution unit 201 and detection Unit 202, Scripting Agent module include:First creating unit 301, the second creating unit 302 and execution unit 303.
Resolution unit 201, for parsing page script.Detection unit 202, in 201 resolving of resolution unit, It determines non-protogenous example script to be created in page script, and the mark of non-protogenous example script to be created is sent to clear Look at the Scripting Agent module of device.
Specifically, detection unit 202 determines that the mode of non-protogenous example script to be created in page script includes:Judge It quotes referent in page script in memory to whether there is, if it is not, then determining that the reference referent is to be created Non-protogenous example script;Alternatively, the keyword acted by characterizing establishment in page script determines example script to be created, and Judge whether the affiliated class of the example script is defined in page script, if it is not, then determining that the example script to be created is Non-protogenous example script to be created.
First creating unit 301 creates and to be created for the mapping relations in preset plug-in description file The corresponding java class example of mark of non-protogenous example script.Second creating unit 302, for real according to the java class created Example creates the determining non-protogenous example script to be created of detection unit 202.
The attribute of above-mentioned mapping relations includes:First attribute and the second attribute, wherein the first attribute is used to describe non-original The title of raw example script or the title of the affiliated class of non-protogenous example script, the second attribute are corresponding with the first attribute for describing The title of java class.
Specifically, the first creating unit 301 creates the mode of corresponding java class example and includes:It determines in each mapping relations The mapping relations that the mark of the property value of first attribute and non-protogenous example script to be created matches, and create by the mapping The example for the java class that the property value of second attribute is specified in relationship.Second creating unit 302 creates non-protogenous foot to be created The mode of this example includes:Non-protogenous example script to be created is determined according to the attribute of the java class example created and method Definition, and the non-protogenous example script is created according to this definition.
Resolution unit 201, when being additionally operable to call the method for non-protogenous example script created in resolving, triggering Execution unit 303 is run, execution unit 303, for calling java class corresponding with the above-mentioned non-protogenous example script created Call result is simultaneously back to resolution unit 201 by the correlation method of example.Wherein correlation method, be exactly in one embodiment with The method that the method for the non-protogenous example script that resolution unit 201 is called has same names.
In addition, mapping relations can also include third attribute, wherein third attribute produces for description according to the mapping relations The valid period of raw object.The property value of the third attribute includes:The effective page during a page is loaded onto destruction Face property value has during a browser is loaded onto down periods effective session attribute value or is interacted with a server The Domain Properties value of effect.
Corresponding, the Scripting Agent module in browser of the invention further may also include a preloading list Member(It is not shown in Fig. 7), for before resolution unit 201 parses page script, determining third property value in plug-in description file For the mapping relations of session attribute value, and create java class example that the mapping relations specify and corresponding with the java class example Non-protogenous example script.
The foregoing is merely illustrative of the preferred embodiments of the present invention, is not intended to limit the invention, all essences in the present invention God and any modification, equivalent substitution, improvement and etc. within principle, done, should be included within the scope of protection of the invention.

Claims (18)

1. a kind of method for extending browser function, including:
A. the script engine module parsing page script of browser, determines to be created in the page script in resolving Non-protogenous example script, and the mark of the non-protogenous example script to be created is sent to the Scripting Agent mould of browser Block;
B. mapping relations of the Scripting Agent module in preset plug-in description file create corresponding with the mark Java class example determines determining for the non-protogenous example script to be created according to the attribute of the java class example and method Justice, and the non-protogenous example script to be created is created according to this definition;
C. when the script engine module calls the method for non-protogenous example script created in resolving, institute is triggered Scripting Agent module is stated to call the correlation method of java class example corresponding with the non-protogenous example script created and incite somebody to action Call result is back to the script engine module.
2. according to the method described in claim 1, it is characterized in that, determine non-protogenous script to be created in the page script The step of example, specifically includes:
Judge that the reference referent in the page script whether there is in memory, if it is not, then determining that the reference is signified Object is non-protogenous example script to be created;Alternatively,
The keyword acted by characterizing establishment in the page script determines example script to be created, and wait to create described in judgement Whether the affiliated class of example script built is defined in the page script, if it is not, then determining that the script to be created is real Example is non-protogenous example script to be created.
3. according to the method described in claim 1, it is characterized in that, the attribute of the mapping relations includes:First attribute and Second attribute, wherein first attribute is used to describe the title of non-protogenous example script or non-protogenous example script affiliated class Title, second attribute are used to describe the title of java class corresponding with first attribute.
4. according to the method described in claim 3, it is characterized in that, the attribute of the mapping relations further includes:Third attribute, Described in third attribute for describing valid period of object for being generated according to the mapping relations.
5. according to the method described in claim 4, it is characterized in that, the property value of the third attribute includes:In a page Effective page attribute values during being loaded onto destruction, a browser be loaded onto down periods effective session attribute value or Effective Domain Properties value during being interacted with a server.
6. according to the method described in claim 3, it is characterized in that, java class example described in the Scripting Agent module creation Step specifically includes:
The Scripting Agent module determines that the property value of the first attribute identifies the mapping to match pass with described in each mapping relations System, and create the example of java class specified by the property value of the second attribute in the mapping relations.
7. the method according to claim 1 or 6, described to identify the name for including the non-protogenous example script to be created Claim, alternatively, the title of the affiliated class of non-protogenous example script to be created.
8. according to the method described in claim 5, it is characterized in that, the method the step A take a step forward including:
The Scripting Agent module determines mapping relations of the third property value for session attribute value in the plug-in description file, and Create java class example and the non-protogenous example script corresponding with the java class example that the mapping relations are specified.
9. according to the method described in claim 1, it is characterized in that, the correlation method is the non-protogenous example script with calling Method have same names method.
A kind of 10. browser, including script engine module and Scripting Agent module, which is characterized in that the script engine Module includes:
Resolution unit, for parsing page script;
Detection unit, for determining non-protogenous script to be created in the page script in the resolution unit resolving Example, and the mark of the non-protogenous example script to be created is sent to the Scripting Agent module of browser;
The Scripting Agent module includes:Execution unit, the first creating unit and the second creating unit;
First creating unit creates corresponding with the mark for the mapping relations in preset plug-in description file Java class example;
Second creating unit determines the non-protogenous to be created for the attribute according to the java class example and method The definition of example script, and the non-protogenous example script to be created is created according to this definition;
When the resolution unit is additionally operable to call the method for non-protogenous example script created in resolving, described in triggering Execution unit is run, wherein the execution unit is for calling java class corresponding with the non-protogenous example script created Call result is simultaneously back to the resolution unit by the correlation method of example.
11. system according to claim 10, which is characterized in that the detection unit determines to wait to create in the page script The mode of non-protogenous example script built specifically includes:
The detection unit judges that the reference referent in the page script whether there is in memory, if it is not, then really The fixed reference referent is non-protogenous example script to be created;Alternatively,
The detection unit determines example script to be created by characterizing the keyword that establishment acts in the page script, and Judge whether the affiliated class of example script to be created is defined in the page script, if it is not, then determining described treat The example script of establishment is non-protogenous example script to be created.
12. system according to claim 10, which is characterized in that the attribute of the mapping relations includes:First attribute with And second attribute, wherein first attribute is for describing the title of non-protogenous example script or the affiliated class of non-protogenous example script Title, second attribute is for describing the title of corresponding with first attribute java class.
13. system according to claim 12, which is characterized in that the attribute of the mapping relations further includes:Third attribute, The valid period of object that wherein described third attribute generates for description according to the mapping relations.
14. system according to claim 13, which is characterized in that the property value of the third attribute includes:In a page Face effective page attribute values during being loaded onto destruction, a browser be loaded onto down periods effective session attribute value, Or effective Domain Properties value during being interacted with a server.
15. system according to claim 10, which is characterized in that first creating unit creates the java class example Mode specifically include:
First creating unit determines that the property value of the first attribute identifies the mapping to match pass with described in each mapping relations System, and create the example of java class specified by the property value of the second attribute in the mapping relations.
16. the system according to claim 10 or 15, which is characterized in that the mark includes the non-protogenous to be created The title of example script, alternatively, the title of the affiliated class of non-protogenous example script to be created.
17. system according to claim 14, which is characterized in that the Scripting Agent module further comprises:
Pre-add carrier unit, for before the resolution unit parses page script, determining third category in the plug-in description file Property value be the mapping relations of session attribute value, and create java class example that the mapping relations specify and with the java class example pair The non-protogenous example script answered.
18. system according to claim 10, which is characterized in that the correlation method is real with the non-protogenous script of calling The method that the method for example has same names.
CN201210237542.1A 2012-07-09 2012-07-09 A kind of method and browser for extending browser function Active CN103543991B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201210237542.1A CN103543991B (en) 2012-07-09 2012-07-09 A kind of method and browser for extending browser function

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201210237542.1A CN103543991B (en) 2012-07-09 2012-07-09 A kind of method and browser for extending browser function

Publications (2)

Publication Number Publication Date
CN103543991A CN103543991A (en) 2014-01-29
CN103543991B true CN103543991B (en) 2018-06-08

Family

ID=49967476

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201210237542.1A Active CN103543991B (en) 2012-07-09 2012-07-09 A kind of method and browser for extending browser function

Country Status (1)

Country Link
CN (1) CN103543991B (en)

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105094773B (en) * 2014-05-09 2018-07-24 阿里巴巴集团控股有限公司 The method for reusing and system of functions of modules
CN105138312B (en) * 2014-06-05 2018-07-03 阿里巴巴集团控股有限公司 A kind of table generation method and device
CN105446709B (en) * 2014-07-29 2019-06-21 阿里巴巴集团控股有限公司 A kind of Java application processing method and device
CN104375858B (en) * 2014-10-27 2017-10-13 深信服网络科技(深圳)有限公司 Many browser platforms perform the method and device of javascript scripts
CN105404502A (en) * 2015-10-20 2016-03-16 浪潮软件集团有限公司 Js component convenient for mobile phone app Sudoku and list development
CN105528209A (en) * 2015-12-03 2016-04-27 河北远东通信系统工程有限公司 Method for converting C# class library into similar ActiveX control and browser loading method
CN106095886B (en) * 2016-06-03 2020-10-09 腾讯科技(深圳)有限公司 Data processing method and device
CN106293746B (en) * 2016-08-12 2020-01-31 福建天晴数码有限公司 Method and system for updating browser script
CN111427622B (en) * 2018-12-24 2023-05-16 阿里巴巴集团控股有限公司 Execution method and device of script codes in application program
CN109857478B (en) * 2019-01-31 2022-03-25 北京小米移动软件有限公司 Target application program running method and device and readable storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101571876A (en) * 2009-05-26 2009-11-04 华为技术有限公司 Script program operation logic expansion method, server and client
CN101639774A (en) * 2009-08-31 2010-02-03 腾讯科技(深圳)有限公司 Encapsulation method of browser control part and device thereof

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101645084A (en) * 2009-04-23 2010-02-10 中国科学院声学研究所 Processing method of dynamic data of embedded browser

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101571876A (en) * 2009-05-26 2009-11-04 华为技术有限公司 Script program operation logic expansion method, server and client
CN101639774A (en) * 2009-08-31 2010-02-03 腾讯科技(深圳)有限公司 Encapsulation method of browser control part and device thereof

Also Published As

Publication number Publication date
CN103543991A (en) 2014-01-29

Similar Documents

Publication Publication Date Title
CN103543991B (en) A kind of method and browser for extending browser function
US8621495B2 (en) Methods and apparatus for securing frames from other frames
US7849437B2 (en) Object oriented web application framework
FI118311B (en) Procedure, data processing apparatus, computer software product and arrangements for processing electronic data
US7703022B2 (en) Display and installation of portlets on a client platform
CN102681850B (en) Method and device for realizing web browsing based on Webkit kernel
WO2016164036A1 (en) Modifying web page code to include code to protect output
WO2009094384A2 (en) A method and apparatus for constructing security policies for web content instrumentation against browser-based attacks
CN107562425A (en) Single-page application creation method and device based on Hybrid applications
CN103577427A (en) Browser kernel based web page crawling method and device and browser containing device
CN103902534B (en) A kind of method and apparatus of web page program triggering local operation
US10423793B2 (en) Install runtime agent for security test
CN102981846A (en) Method for treating password input box element and browser for treating the password input box element
CN110059278A (en) Web page configuration method, server and computer readable storage medium
CN104731598B (en) A kind of method and device that web page browsing is provided based on Webkit kernels
Chen et al. An analysis of browser domain-isolation bugs and a light-weight transparent defense mechanism
CN111651169B (en) Block chain intelligent contract operation method and system based on web container
CN111813385B (en) Page plug-in method, device and equipment based on Web application
CN103544209A (en) Method and system for web page access
CN111679828A (en) Data processing method and device, electronic equipment and storage medium
CN109067818B (en) A kind of business access method and device
US7010454B1 (en) Test services provider
CN108509229A (en) Method, terminal device and the computer readable storage medium of the cross-domain control of window
CN114756229A (en) Development page generation method based on micro front end and related device thereof
CN112416612B (en) Service calling method and device, computer equipment and readable storage medium

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
EXSB Decision made by sipo to initiate substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant