It is on October 19th, 2012 that the application, which is the applying date, and application number is 201210401336.X, and title is " in browser
Message sending device and receiving device and method and system " application for a patent for invention divisional application.
Specific embodiment
Exemplary embodiments of the present disclosure are described in more detail below with reference to accompanying drawings.Although showing the disclosure in attached drawing
Exemplary embodiment, it being understood, however, that may be realized in various forms the disclosure without should be by embodiments set forth here
It is limited.On the contrary, these embodiments are provided to facilitate a more thoroughly understanding of the present invention, and can be by the scope of the present disclosure
It is fully disclosed to those skilled in the art.
It is specific with reference to the accompanying drawing to introduce the present invention.
Fig. 1 shows the block diagram of the message sending device in a kind of browser of embodiment according to the present invention.This disappears
Sending device is ceased to be used to send the message of source web page to target webpage.As shown in Figure 1, message sending device 100 includes first
Judging device 110, standard message transmitter 120 and customization message sender 130.
First judging device 110 determines whether browser supports message transfer mechanism between domain, such as HTML5.It is clear when determining
When device of looking at supports message transfer mechanism between domain, the messaging of source web page to be sent to standard message transmitter 120;When
When first judging device 110 determines that current browser does not support message transfer mechanism between domain, the message of source web page to be sent
It is sent to customization message sender 130.
Standard message transmitter 120 is sent to by the message of the message mode source web page to be sent between domain
Target webpage.For example, the mode that HTML5 takes postMessage to apply sends message.With the javascript generation in HTML5
For code, if necessary to send message to target webpage, standard message transmitter 120 can use following code to carry out:
windowObject.postMessage(data,'*');
Wherein, windowObject indicates the window object of target webpage;Data indicates source web page information to be sent, can
Message is sent to call directly postMessage.
It customizes message sender 130 and passes through the message of the particular attribute-value source web page to be sent of modification target webpage
It is sent to target webpage.Wherein, the particular attribute-value for indicating the transmission of net message between domains can be the name attribute of window object
The attribute value of value or other attributes, is also possible to the attribute value of more than two attributes.
By taking javascript code as an example, if necessary to send message to target webpage, customization message sender 130 can be with
It is carried out using following code:
WindowObject.name=data;
Wherein windowObject indicates the window object of target webpage;Data indicates source web page information to be sent, fixed
Message generator 130 processed realizes that message is sent out by the way that the name attribute value of modification target pages window object is message to be sent
It send.
The message sending device 100 in browser shown in FIG. 1 both can be used for source web page above and target webpage is located at
The situation of identical URL/domain, and can be used for source web page and target webpage is located at the situation of different URL/domains.For example, source web page
It can be the different web pages in the same domain abc.example.com with target webpage, can also be to be located at source web page
The webpage of abc.example.com and target webpage are the webpages positioned at def.example.com.
Further optionally, the message sending device 100 in the browser of Fig. 1 can only include customization message sender
130.No matter whether target webpage supports message transfer mechanism between domain, such as HTML5.Customization message sender 130 all passes through
Modify target webpage particular attribute-value (such as name attribute value of window object) and the message of source web page to be sent
It is sent to target webpage.
Fig. 2 shows a kind of flow charts of the message method 200 of the browser of embodiment according to the present invention.Such as
Shown in Fig. 2, which starts from step S205, then, in step S210, determines whether browser supports domain
Between message transfer mechanism, such as HTML5, between determining that browser supports domain when message transfer mechanism, this method is entered step
S220, wherein message of the message of source web page to be sent by the message mode source web page to be sent between domain
It is sent to target webpage.For example, the mode that source web page can take postMessage to apply sends message to target webpage.When
Between step S210 determines that current browser does not support domain when message transfer mechanism, then this method enters step S230, wherein
Message by modifying the particular attribute-value source web page to be sent of target webpage is sent to target webpage.Target webpage
Particular attribute-value can be the name attribute value of window object or the attribute value of other attributes, be also possible to more than two
The attribute value of attribute.After step S220 or step S230, message method of the invention is terminated with step S235.
In message method 200 in browser shown in fig. 2 above, source web page and target webpage can be located at phase
With URL/domain or positioned at different URL/domains.For example, the two can be located at the difference in the same domain abc.example.com
Webpage, can also be with source web page positioned at abc.example.com webpage and target webpage positioned at def.example.com
Webpage.
Further optionally, the message method in browser shown in Fig. 2 can only include step: by modifying mesh
The message for marking the particular attribute-value source web page to be sent of webpage is sent to target webpage.In this embodiment, no matter
Whether target webpage supports message transfer mechanism between domain, all by modifying the particular attribute-value of target webpage for source web page
Message is sent to target webpage.
Fig. 3 shows the block diagram of the message reception facility 300 in a kind of browser of embodiment according to the present invention.Disappear
Breath receiving device 300 makes target webpage receive the message from source web page.As shown in figure 3, message reception facility 300 includes second
Judging device 310, standard message receiver 320 and customization message receiver 330.
Second judging device 310 determines whether browser supports message transfer mechanism between domain.When the second judging device 310 determines
Between browser support domain when message transfer mechanism, the message from the source page is received by standard message receiver 320;When
When two judging devices 310 determine that current browser does not support message transfer mechanism between domain, the customization reception of message receiver 330 is come from
The message of the source page.
Standard message receiver 320 receives the message from source web page with the message receiving mode between domain.For example, source
Webpage and target webpage support the transmission of net message between domains, then standard message receiver 320 can be taken opposite with postMessage
The mode answered receives the message from source web page.
By taking javacript code as an example, standard message receiver 320 receives message in the following manner:
Wherein, function of the wan360.xdomain.handler to handle received message.It is received in standard message
In device 320, when it receives a message, corresponding event can be triggered (according to different browser versions, it may be possible to message
Event or onmessage event), the event is monitored by being registered as wan360.xdomain.handler, when webpage is received
When to message, corresponding event can be triggered, and the wan360.xdomain.handler of monitor event will receive the message simultaneously
It is handled.
Whether the particular attribute-value of customization 330 regular check target webpage of message receiver changes, if specified genus
Property value changes, then handles the particular attribute-value to obtain the message from source web page.Wherein, the particular attribute-value of webpage can
Think the name attribute value of window object or the attribute value of other attributes, is also possible to the attribute of more than two attributes
Value.
By taking javacript code as an example, customization message receiver 330 receives message in the following manner:
In the above example, cb is the function for handling message, by periodically going the name value for checking window object to be
It is no change or whether be it is empty, when name value changes, illustrate to have received message, at this moment can be handled by cb
The message.
Optionally, message reception facility 300 shown in Fig. 3 can also include message processing device (such as in above example
Cb), processing by standard message receiver 320 and customization message receiver 330 the received message from source web page.It can
Selection of land, the message processing device are independently of message reception facility 300 and are arranged.
Optionally, standard message receiving device 320 includes: monitor 3210, is monitored whether from the message of source web page;
It triggers when there is the message from source web page with trigger 3210 and receives the message.
Optionally, customization message receiver 330 includes timer 3310, the particular attribute-value of regular check target webpage
Whether change and is not sky.
The message reception facility 300 in browser shown in Fig. 3 both can be used for source web page above and target webpage is located at
The situation of identical URL/domain, can be used for source web page and target webpage is located at the situation of different URL/domains.For example, source web page
It can be the different web pages in the same domain abc.example.com with target webpage, can also be to be located at source web page
The webpage of abc.example.com and target webpage are the webpages positioned at def.example.com.
Further optionally, the message sending device 300 in browser shown in Fig. 3 can only include customization message sink
Device 330.No matter whether target webpage supports message transfer mechanism between domain, such as HTML5, customization message receiver 330 all fixed
When check target webpage particular attribute-value whether change, if particular attribute-value changes, handle the specified genus
Property value is to obtain the message from source web page.
Fig. 4 shows a kind of flow chart of the message receival method 400 of the browser of embodiment according to the present invention, uses
In make target webpage receive the message from source web page.As shown in figure 4, the message receival method 400 starts from step S405, with
Afterwards, in step S410, determine whether browser supports message transfer mechanism between domain, for example whether supporting HTML5.It is clear when determining
Between device of looking at support domain when message transfer mechanism, S420 is thened follow the steps, is come from the message receiving mode between domain to receive
The message of source web page.It is received using corresponding mode from source web page for example, target webpage can be taken with postMessage
Message.In step S410, when determining that current browser does not support message transfer mechanism between domain, then this method is entered step
S430, wherein whether the particular attribute-value of regular check target webpage changes, if particular attribute-value changes, locates
The particular attribute-value is managed to obtain the message from source web page.Wherein, the particular attribute-value of webpage can be window object
The attribute value of name attribute value or other attributes is also possible to the attribute value of more than two attributes.
Can directly it be terminated after step S420 or step S430 with step S445, optionally, in step S420 or step
After rapid S430, message receival method 400 can also include step S440, wherein handle the disappearing from source web page received
Breath, for being shown in target webpage.Then, then with step S445 terminate.
The message receival method in browser shown in Fig. 4 both can be used for source web page and target webpage positioned at identical above
URL/domain situation, can be used for source web page and target webpage be located at the situation of different URL/domains.For example, source web page and mesh
Mark webpage can be the different web pages in the same domain abc.example.com, can also be to be located at source web page
The webpage of abc.example.com and target webpage are the webpages positioned at def.example.com.
Fig. 5 shows a kind of block diagram of the communication system 500 of the browser of embodiment according to the present invention, is used for source
Communication between webpage and target webpage.As shown in figure 5, the communication system 500 of browser of the invention includes shown in Fig. 1
Message reception facility 300 shown in message sending device 100 and Fig. 3.Wherein, message sending device 100 includes shown in Fig. 1
The first judging device 110, standard message transmitter 120 and customization message sender 130.Message reception facility 300 includes Fig. 1
Shown in the second judging device 310, standard message receiver 320 and customization message receiver 330.
Specifically, the first judging device 110 in message sending device 100 determines whether browser supports net message between domains to pass
Defeated mechanism, such as HTML5.Between determining that browser supports domain when message transfer mechanism, the message of source web page to be sent
It is sent to standard message transmitter 120.Standard message transmitter 120 is by the message of source web page with the message mode between domain
It is sent to the second judging device 310 of message reception facility 300.Second judging device 310 determines whether browser is supported to disappear between domain
Transmission mechanism is ceased, between determining that browser supports domain when message transfer mechanism, the source of coming from is received by standard message receiver 320
The message of the page.
Between the first judging device 110 determines that browser does not support domain when message transfer mechanism, source web page to be sent
Messaging to customization message sender 130.It customizes message sender 130 and passes through the particular attribute-value of modification target webpage
The message of source web page to be sent is sent to the second judging device 310 of message reception facility 300, and the second judging device 310 determines
Whether browser supports message transfer mechanism between domain, between determining that browser does not support domain when message transfer mechanism, by fixed
Whether the particular attribute-value of 330 regular check target webpage of message receiver processed changes, if particular attribute-value becomes
Change, then handles the particular attribute-value to obtain the message from source web page.
Optionally, the communication system of browser of the invention can also include message handling device 510.Message handling device 510
Handle the 330 received message of institute of standard message receiver 320 or customization message receiver.
The communication system 500 of browser of the invention both can be used for source web page and target webpage is located at identical URL/domain
Situation, and can be used for source web page and target webpage is located at the situation of different URL/domains.For example, source web page and target webpage
It can be the different web pages being located in the same domain abc.example.com, can also be to be located at source web page
The webpage of abc.example.com and target webpage are the webpages positioned at def.example.com.
Further optionally, the message sending device 100 in the communication system 500 of browser of the invention can only include
Message sender 130 is customized, correspondingly, message reception facility 300 can only include customization message sender 330.In this feelings
Under shape, no matter whether target webpage supports net message between domains to transmit, and customization message sender 130 all passes through modification target webpage
Particular attribute-value (such as name attribute value of window object) and the message of source web page to be sent is sent to target webpage,
Correspondingly, whether the particular attribute-value for customizing all regular check target webpages of message receiver 330 changes, if specified genus
Property value changes, then handles the particular attribute-value to obtain the message from source web page.
In addition, the communication system 500 of browser of the invention can be as described above, message sending device 100 therein be set
It is placed in source web page, and message reception facility 300 is set in target webpage, so that target webpage can always receive to come
From the message of source web page.But the communication system 500 of browser of the invention is not limited to this, in source web page and target webpage all
It can both include message sending device 100, also include message reception facility 300, so that any one webpage all can both have been sent
Message also can receive message.
It is said in more detail below by communication system 500 of the specific example to browser of the invention
It is bright.
In this example embodiment, the communication system 500 of browser of the invention makes a webpage being located in the first domain a.com
Cross-domain communication is carried out between webpage child.html in parent.html and its second domain b.com being embedded in by iframe.
Wherein, the webpage parent.html in the first domain is source web page, and the webpage child.html in the second domain is known as target webpage.
Webpage parent.html in first domain has message sending device 100, by sendMessage be responsible for
Target webpage sends message.Webpage child.html in second domain has message reception facility 300 and message handling device 510,
Message reception facility 300 is responsible for receiving the message that sends over of source web page and message is transferred to message handling device by monitoring
510 are handled.
Message sending device 100 has the first judging device 110, standard message transmitter 120 and customization message sender
130.Wherein the first judging device 110 judges whether browser supports HTML5, such as Firefox, IE8+, Opera, Safari,
Chrome is the browser for supporting HTML5, and IE6 and IE7 is the browser for not supporting HTML5.When judgement browser is supported
When HTML5, standard message transmitter 120 sends a message to target webpage by the postMessage function of HTML5, otherwise,
It customizes message sender 130 and message is sent to target webpage by the name attribute of the window object in modification target webpage.
Message reception facility 300 includes the second judging device 310, standard message receiver 320 and customization message receiver
330.Wherein, the second judging device 310 judges whether browser supports HTML5, if it is decided that browser supports HTML5, then standard
Message receiver 320 passes through addEventListener or attachEvent (supporting situation selection depending on browser) addition message
Monitoring event, such as it is an event that source web page, which carrys out message, obtains the message of source web page transmitting by event triggering, then will disappear
Breath is given message handling device 510 and is handled;Otherwise, message receiver 330 is customized by the window of timing probe target webpage
The name attribute value of object obtains the message that the source page is sent, then gives when name attribute value changes and is not empty
Message handling device 510 is handled.In addition, the present invention also provides a kind of a kind of browsers of embodiment according to the present invention
The flow chart of communication means 600, as shown in fig. 6, it is used for the communication between source web page and target webpage.The communication of the browser
Then method executes message method shown in Fig. 2, executes message sink shown in Fig. 4 later such as in step S605
Then method terminates the communication means with step S665.About aforementioned messages sending method referring specifically to being previously with regard to retouching for Fig. 2
It states, such as aforementioned messages method of reseptance referring specifically to description as described in being previously with regard to Fig. 4, description is not repeated herein.
In summary, in order to realize that the Web page (hereinafter referred to as " source web page ") of browser for using HTML5 passes through with it
Cross-domain communication between the Web page (hereinafter referred to as " target webpage ") of the not same area of iframe insertion, the present invention first determine whether
Whether target webpage supports HTML5, if supporting HTML5, is answered using message mode, that is, postMessage of HTML5
With being communicated, if not supporting HTML5, the hair of message is completed by the name attribute of modification target webpage window object
It send, and target webpage is then by judging whether the value of the name attribute of window object changes or whether to be sky judge
Whether message is received, it is possible thereby to realize the cross-domain communication between the not Web page of same area.
Algorithm and display are not inherently related to any particular computer, virtual system, or other device provided herein.
Various general-purpose systems can also be used together with teachings based herein.As described above, it constructs required by this kind of system
Structure be obvious.In addition, the present invention is also not directed to any particular programming language.It should be understood that can use various
Programming language realizes summary of the invention described herein, and the description done above to language-specific is to disclose this hair
Bright preferred forms.
In the instructions provided here, numerous specific details are set forth.It is to be appreciated, however, that implementation of the invention
Example can be practiced without these specific details.In some instances, well known method, structure is not been shown in detail
And technology, so as not to obscure the understanding of this specification.
Similarly, it should be understood that in order to simplify the disclosure and help to understand one or more of the various inventive aspects,
Above in the description of exemplary embodiment of the present invention, each feature of the invention is grouped together into single implementation sometimes
In example, figure or descriptions thereof.However, the disclosed method should not be interpreted as reflecting the following intention: i.e. required to protect
Shield the present invention claims features more more than feature expressly recited in each claim.More precisely, as following
Claims reflect as, inventive aspect is all features less than single embodiment disclosed above.Therefore,
Thus the claims for following specific embodiment are expressly incorporated in the specific embodiment, wherein each claim itself
All as a separate embodiment of the present invention.
Those skilled in the art will understand that can be carried out adaptively to the module in the equipment in embodiment
Change and they are arranged in one or more devices different from this embodiment.It can be the module or list in embodiment
Member or component are combined into a module or unit or component, and furthermore they can be divided into multiple submodule or subelement or
Sub-component.Other than such feature and/or at least some of process or unit exclude each other, it can use any
Combination is to all features disclosed in this specification (including adjoint claim, abstract and attached drawing) and so disclosed
All process or units of what method or apparatus are combined.Unless expressly stated otherwise, this specification is (including adjoint power
Benefit require, abstract and attached drawing) disclosed in each feature can carry out generation with an alternative feature that provides the same, equivalent, or similar purpose
It replaces.
In addition, it will be appreciated by those of skill in the art that although some embodiments described herein include other embodiments
In included certain features rather than other feature, but the combination of the feature of different embodiments mean it is of the invention
Within the scope of and form different embodiments.For example, in the following claims, embodiment claimed is appointed
Meaning one of can in any combination mode come using.
Various component embodiments of the invention can be implemented in hardware, or to run on one or more processors
Software module realize, or be implemented in a combination thereof.It will be understood by those of skill in the art that can be used in practice
Microprocessor or digital signal processor (DSP) realize one of some or all components according to embodiments of the present invention
A little or repertoire.The present invention is also implemented as setting for executing some or all of method as described herein
Standby or program of device (for example, computer program and computer program product).It is such to realize that program of the invention deposit
Storage on a computer-readable medium, or may be in the form of one or more signals.Such signal can be from because of spy
It downloads and obtains on net website, be perhaps provided on the carrier signal or be provided in any other form.
It should be noted that the above-mentioned embodiments illustrate rather than limit the invention, and ability
Field technique personnel can be designed alternative embodiment without departing from the scope of the appended claims.In the claims,
Any reference symbol between parentheses should not be configured to limitations on claims.Word "comprising" does not exclude the presence of not
Element or step listed in the claims.Word "a" or "an" located in front of the element does not exclude the presence of multiple such
Element.The present invention can be by means of including the hardware of several different elements and being come by means of properly programmed computer real
It is existing.In the unit claims listing several devices, several in these devices can be through the same hardware branch
To embody.The use of word first, second, and third does not indicate any sequence.These words can be explained and be run after fame
Claim.
The invention discloses:
A1, a kind of message sending device should suitable in a browser sending the message from source web page to target webpage
Message sending device includes:
Message sender is customized, the message of the particular attribute-value source web page to be sent by modifying target webpage
It is sent to target webpage.
A2, message sending device as described in a1, further include:
Standard message transmitter is sent to mesh by the message of the source web page to be sent of message mode between domain
Mark webpage;And
First judging device, determines whether the browser supports message transfer mechanism between domain, when the judgement browsing
When device supports message transfer mechanism between domain, the messaging of source web page to be sent to the standard message transmitter, when
When first judging device determines message transfer mechanism between the browser does not support domain, the messaging of source web page to be sent
To the customization message sender.
A3, message sending device as described in a1 or a2, wherein source web page and target webpage belong to different URL/domains.
A4, the message sending device as described in any one of A1-A3, wherein the particular attribute-value is window couples
The name attribute value of elephant.
B5, a kind of message method, for the message from source web page to be sent to target webpage in a browser, packet
Include step:
Message by modifying the particular attribute-value source web page to be sent of target webpage is sent to target webpage.
B6, the message method according to B5, further comprise the steps of:
Determine whether browser supports message transfer mechanism between domain,
Between determining that the browser supports domain when message transfer mechanism, the message of source web page to be sent passes through net
The message of message between domains sending method source web page to be sent is sent to target webpage, and
Between determining that the browser does not support domain when message transfer mechanism, using described by modifying target webpage
Particular attribute-value and the message of source web page to be sent is sent to target webpage to send message.
B7, the message method according to B5 or B6, wherein source web page and target webpage belong to different URL/domains.
B8, the message method according to any one of B5-B7, wherein the particular community of the target webpage
Value is the name attribute value of window object.
C9, a kind of message reception facility, suitable for receiving the message from source web page from target webpage in a browser, this disappears
Ceasing receiving device includes:
Message receiver is customized, whether the particular attribute-value of regular check target webpage changes, if the spy
Determine attribute value to change, then handles the particular attribute-value to obtain the message from source web page.
C10, the message reception facility according to C9, further includes:
Standard message receiver receives the message from source web page with message receiving mode between domain;With
Second judging device, determines whether the browser supports message transfer mechanism between domain, when the judgement browsing
Between device support domain when message transfer mechanism, the message from the source page is received by the standard message receiver, when second
When judging device determines message transfer mechanism between the browser does not support domain, received by the customization message receiver from source
The message of the page.
C11, the message reception facility as described in C9 or C10, wherein the source web page and the target webpage belong to difference
URL/domain.
C12, the message reception facility according to any of C9-C11, wherein
The standard message receiver includes:
Monitor is monitored whether from the message of source web page;With
Trigger triggers and receives the message when there is the message from source web page,
The customization message receiver includes:
Whether the particular attribute-value of timer, regular check target webpage changes and is not sky.
C13, the message reception facility according to any one of C9-C12, further includes:
Message handling device, handle the standard message receiver or the customization message receiver received disappear
Breath.
C14, the message reception facility as described in any one of C9-C13, wherein
The particular attribute-value of the target webpage is the name attribute value of window object.
D15, a kind of message receival method, for making the target webpage in browser receive the message from source web page, institute
State message receival method comprising steps of
Whether the particular attribute-value of regular check target webpage changes, if the particular attribute-value changes,
Handle the particular attribute-value then to obtain the message from source web page.
D16, the message receival method according to D15, further include following steps:
Determine whether browser supports message transfer mechanism between domain,
Between determining that the browser supports domain when message transfer mechanism, come with message receiving mode between domain to receive
From the message of source web page, and
Between determining that the browser does not support domain when message transfer mechanism, the particular community of regular check target webpage
Whether value changes, if the particular attribute-value changes, handles the particular attribute-value to obtain and come from source web page
Message.
D17, the message receival method according to D15 or D16, wherein the source web page and the target webpage belong to not
Same URL/domain.
D18, the message receival method according to D15-D17, wherein
The particular attribute-value of the target webpage is the name attribute value of window object.
E19, a kind of communication system of browser, the communication being used between source web page and target webpage, the source web page
And target webpage respectively include:
The message sending device according to any one of A1, A3 and A4;And
The message reception facility according to any one of C9 and C11-C14.
F20, a kind of communication system of browser, the communication being used between source web page and target webpage, the source web page
And target webpage respectively include:
The message sending device according to any one of A2, A3 and A4;And
The message reception facility according to any one of C10 and C11-C14.
G21, a kind of communication means of browser, the communication being used between source web page and target webpage, the communication means
Include:
The message method according to B5;And
The message receival method according to D15.
H22, a kind of communication means of browser, the communication being used between source web page and target webpage, the communication means
Include:
The message method according to any one of B6-B8;And
The message receival method according to any one of D16-D18.