CN104410722A - Method and system for communication of Web page window objects - Google Patents
Method and system for communication of Web page window objects Download PDFInfo
- Publication number
- CN104410722A CN104410722A CN201410814706.1A CN201410814706A CN104410722A CN 104410722 A CN104410722 A CN 104410722A CN 201410814706 A CN201410814706 A CN 201410814706A CN 104410722 A CN104410722 A CN 104410722A
- Authority
- CN
- China
- Prior art keywords
- window object
- message event
- message
- web page
- send
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/02—Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Information Transfer Between Computers (AREA)
- Computer And Data Communications (AREA)
Abstract
The invention provides a method and a system for communication of Web page window objects. The method for communication of Web page window objects comprises the following steps: calling the message sending function of a sending window object to send a message event to a target window object, wherein the message event comprises data to be sent and a source attribute taking the sending window as a source; enabling the target window object to call a monitoring function to monitor the message event, and displaying the data in the message event obtained by monitoring when determining that the message event obtained by monitoring comes from the sending window object according to the source attribute of the message event obtained by monitoring. According to the invention, the cross-domain cross-Webpage communication can be implemented in a simple and convenient way with a better user experience.
Description
Technical field
The present invention relates to a kind of communication technical field, particularly relate to a kind of communication means and system of Web page window object.
Background technology
A html page can have one or more Web subpage frame, can nested Web subpage frame in Web subpage frame, and these Web subpage frames may belong to different territories, and also has the demand intercomed mutually between the Web subpage frame of not same area.Such as on stream we often to need father and son's page to realize cross-domain.Communicate from the angle of fail safe, any content from other website dynamic loadings, its fail safe is all unknowable, so for browser, when requiring dynamic content, only should read HTTP response and the Cookies of homology, and the content of not homology can not be read.Due to the restriction of same source policy, the problem that JavaScript is cross-domain, is one always and compares stubborn problem.There is the multiple scheme overcoming the restriction of same source policy at present, but be substantially all utilize act on behalf of the page, also just inevitably to produce network request, for these expenses, sizable pressure may be produced to server at the website of visit capacity super large.Existing method mainly contains the problem of two aspects, and 1, fail safe.After a website is attacked, another website can cause security breaches, or data are directly leaked in URL cruelly.If introduce an iframe in 2 one pages, want to operate all iframe, identical domain must be set, data capacity and limited types.So need badly design a kind of can be simple and convenient realize cross-domain, across the communication means of Web page.
Summary of the invention
The shortcoming of prior art in view of the above, the object of the present invention is to provide a kind of communication means and system of Web page window object, for solving in prior art and problem that consumption of natural resource larger comparatively complicated across Web page communication.
For achieving the above object and other relevant objects, the message that the communication means that the invention provides a kind of Web page window object comprises the steps: to call send window object sends function to target window object transmission message event, wherein, described message event comprises: data to be sent and with described send window object for source source attribute; Described target window object reference is monitored function and is monitored described message event, when judging that it derives from described send window object according to the source attribute of listened to message event, shows the data in the message event listened to.
Optionally, described target window object, when judging that it derives from described send window object according to the source attribute of listened to message event, continues the source whether trusted judging described message event; When for being, show the data in described message event; When for time no, show error message.
Optionally, after calling the message transmission function of described send window object, the address according to described target window object sends message event to target window object.
Optionally, the address of described target window object is URL form.
Optionally, described send window object can send message event to multiple described target window object simultaneously.
Optionally, it is postMessage function that described message sends function, and described monitoring function is addEventListener function.
Optionally, described send window object is in the first Web page, and described target window object is in the second Web page.
For achieving the above object and other relevant objects, the present invention also provides a kind of communication system of Web page window object to comprise: sending module, the message calling send window object sends function and sends message event to target window object, wherein, described message event comprises: data to be sent and with described send window object for source source attribute; Monitor module, make described target window object reference monitor function and described message event is monitored; Judge display module, when the source attribute of the message event listened to according to described monitoring module judges that it derives from described send window object, show the data in the message event listened to.
Optionally, described judgement display module, when the source attribute of the message event listened to according to described monitoring module judges that it derives from described send window object, continues to judge whether the source attribute of described message event is trusted; When for being, show the data in described message event; When for time no, show error message.
Optionally, described sending module, the message calling described send window object sends function, and sends message event according to the address of described target window object to target window object; The address of wherein said target window object is URL form.
As mentioned above, the communication means of a kind of Web page window object of the present invention and system, the message calling send window object sends function and sends message event to target window object, wherein, described message event comprises: data to be sent and with described send window object for source source attribute; Described target window object reference is monitored function and is monitored described message event, when judging that it derives from described send window object according to the source attribute of listened to message event, shows the data in the message event listened to.The present invention can realize with a kind of simple and convenient mode realize cross-domain, across the communication of Web page, better user experience.
Accompanying drawing explanation
Fig. 1 is shown as the schematic flow sheet of the communication means of a kind of Web page window object of the present invention.
Fig. 2 is shown as the principle flow chart of the communication means applying a kind of Web page window object of the present invention.
Fig. 3 is shown as the principle flow chart of the communication means applying a kind of Web page window object of the present invention.
Fig. 4 is shown as the communication system module schematic diagram of a kind of Web page window object of the present invention.
Element numbers explanation
The communication system of 1 Web page window object
11 sending modules
12 monitor module
13 judge display module
S11, S12 step
Embodiment
Below by way of specific instantiation, embodiments of the present invention are described, those skilled in the art the content disclosed by this specification can understand other advantages of the present invention and effect easily.The present invention can also be implemented or be applied by embodiments different in addition, and the every details in this specification also can based on different viewpoints and application, carries out various modification or change not deviating under spirit of the present invention.It should be noted that, when not conflicting, the feature in following examples and embodiment can combine mutually.
It should be noted that, the diagram provided in following examples only illustrates basic conception of the present invention in a schematic way, then only the assembly relevant with the present invention is shown in diagram but not component count, shape and size when implementing according to reality is drawn, it is actual when implementing, and the kenel of each assembly, quantity and ratio can be a kind of change arbitrarily, and its assembly layout kenel also may be more complicated.
Refer to Fig. 1, be shown as the schematic flow sheet of the communication means of a kind of Web page window object of the present invention.
Described method comprises the steps:
S11: the message calling send window (window) object sends function and sends message event to target window object, such as, after calling the message transmission function of described send window object, address according to described target window object sends message event to target window object, wherein, described message event comprises: data to be sent and with described send window object for source source attribute, the address of described target window object is URL form.Such as described send window object is in the first Web page, and described target window object is in the second Web page.Described first Web page is the parent page of described second Web page.Preferably, described send window object can send message event to multiple described target window object simultaneously.
S12: described target window object reference is monitored function and monitored described message event, when judging that it derives from described send window object according to the source attribute of listened to message event, shows the data in the message event listened to.
In another specific embodiment, described target window object, when judging that it derives from described send window object according to the source attribute of listened to message event, continues the source whether trusted judging described message event; When for being, show the data in described message event; When for time no, show error message.
Refer to Fig. 2, be shown as the principle flow chart of the communication means applying a kind of Web page window object of the present invention, in the present embodiment, it is postMessage function that described message sends function, a message is put into (sending) to being associated in message queue with the thread that specified window creates by this function, not waiting for that thread processing messages just returns, is asynchronous message pattern.In HTML5, increased postMessage method newly, postMessage can realize transmitting across document message.Described monitoring function is addEventListener, and it can be intercepted event and carry out respective handling to event.First, in first WEB page, perform script, location calibration window object also calls postMessage function, the Window.postMessage () namely shown in Fig. 3; Then, in second WEB page, perform script, call the addEventListener function of window (window) object, the window.addEventListener () function namely shown in Fig. 3; When message (Message) event occurs, check source (origin) attribute of MessageEvent object, give second page by the Message Transmission of first page.
Such as, described Window.postMessage () is window.postMessage (" I like apples ", " http://phicomm:81 "), wherein, " I like apples " Message-text for namely sending, " http://phicomm:81 " is the url address of the window accepting message.Monitoring function addEventListener () in second page is monitored event message, and described monitoring function is specially:
Namely after monitoring function addEventListener () listens to message event, the source attribute (origin attribute) of message event is judged, when for trusted, i.e. e.origin==http: during //phicomm, data in message event are shown, i.e. displayMessage (e.data); When e.origin is not http://phicomm, display error message Message Discarded, i.e. displayMessage (" Message Discarded ").
Present invention also offers a kind of communication system of Web page window object, refer to Fig. 4, be shown as the communication system module diagram in one embodiment of a kind of Web page window object of the present invention, described system 1 comprises sending module 11, monitors module 12 and judge display module 13.
Described sending module 11, the message calling send window object sends function and sends message event to target window object, such as, after calling the message transmission function of described send window object, address according to described target window object sends message event to target window object, wherein, described message event comprises: data to be sent and with described send window object for source source attribute, the address of described target window object is URL form.Such as described send window object is in the first Web page, and described target window object is in the second Web page.Described first Web page is the parent page of described second Web page.It is such as postMessage () function that described message sends function, and preferably, described send window object can send message event to multiple described target window object simultaneously.
Described monitoring module 12 makes described target window object reference monitor function and monitors described message event; Described monitoring function is such as addEventListener () function.
Described judgement display module 13, when the source attribute of the message event listened to according to described monitoring module 12 judges that it derives from described send window object, shows the data in the message event listened to.
In another specific embodiment, described judgement display module 13, when the source attribute of the message event listened to according to described monitoring module 12 judges that it derives from described send window object, continues the source whether trusted judging described message event; When for being, show the data in described message event; When for time no, show error message.
The know-why of native system embodiment is roughly the same with above-described embodiment, and when not conflicting, the feature in above-described embodiment all can be applicable to this method embodiment, and therefore to the technical characteristic repeated, it is no longer repeated.
In sum, the communication means of a kind of Web page window object of the present invention and system, the message calling send window object sends function and sends message event to target window object, wherein, described message event comprises: data to be sent and with described send window object for source source attribute; Described target window object reference is monitored function and is monitored described message event, when judging that it derives from described send window object according to the source attribute of listened to message event, shows the data in the message event listened to.The present invention can realize with a kind of simple and convenient mode realize cross-domain, across the communication of Web page, better user experience.So the present invention effectively overcomes various shortcoming of the prior art and tool high industrial utilization.
Above-described embodiment is illustrative principle of the present invention and effect thereof only, but not for limiting the present invention.Any person skilled in the art scholar all without prejudice under spirit of the present invention and category, can modify above-described embodiment or changes.Therefore, such as have in art usually know the knowledgeable do not depart from complete under disclosed spirit and technological thought all equivalence modify or change, must be contained by claim of the present invention.
Claims (10)
1. a communication means for Web page window object, is characterized in that, comprises the steps:
Call send window object message send function to target window object send message event, wherein, described message event comprises: data to be sent and with described send window object for source source attribute;
Making described target window object reference monitor function monitor described message event, when judging that it derives from described send window object according to the source attribute of listened to message event, showing the data in the message event listened to.
2. the communication means of Web page window object according to claim 1, it is characterized in that: described target window object, when judging that it derives from described send window object according to the source attribute of listened to message event, continues the source whether trusted judging described message event; When for being, show the data in described message event; When for time no, show error message.
3. the communication means of Web page window object according to claim 1, is characterized in that: after calling the message transmission function of described send window object, the address according to described target window object sends message event to target window object.
4. the communication means of Web page window object according to claim 3, is characterized in that: the address of described target window object is URL form.
5. the communication means of Web page window object according to claim 1, is characterized in that: described send window object can send message event to multiple described target window object simultaneously.
6. the communication means of Web page window object according to claim 1, is characterized in that: it is postMessage function that described message sends function, and described monitoring function is addEventListener function.
7. the communication means of Web page window object according to claim 1, is characterized in that: described send window object is in the first Web page, and described target window object is in the second Web page.
8. a communication system for Web page window object, is characterized in that: comprising:
Sending module, call send window object message send function to target window object send message event, wherein, described message event comprises: data to be sent and with described send window object for source source attribute;
Monitor module, make described target window object reference monitor function and described message event is monitored;
Judge display module, when the source attribute of the message event listened to according to described monitoring module judges that it derives from described send window object, show the data in the message event listened to.
9. the communication system of Web page window object according to claim 8, is characterized in that:
Described judgement display module, when the source attribute of the message event listened to according to described monitoring module judges that it derives from described send window object, continues to judge whether the source attribute of described message event is trusted; When for being, show the data in described message event; When for time no, show error message.
10. the communication system of Web page window object according to claim 8, is characterized in that:
Described sending module, the message calling described send window object sends function, and sends message event according to the address of described target window object to target window object;
The address of wherein said target window object is URL form.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410814706.1A CN104410722A (en) | 2014-12-19 | 2014-12-19 | Method and system for communication of Web page window objects |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410814706.1A CN104410722A (en) | 2014-12-19 | 2014-12-19 | Method and system for communication of Web page window objects |
Publications (1)
Publication Number | Publication Date |
---|---|
CN104410722A true CN104410722A (en) | 2015-03-11 |
Family
ID=52648317
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201410814706.1A Pending CN104410722A (en) | 2014-12-19 | 2014-12-19 | Method and system for communication of Web page window objects |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104410722A (en) |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105677536A (en) * | 2016-01-08 | 2016-06-15 | 上海斐讯数据通信技术有限公司 | Implementing method for task messages and task system for implementing task messages |
CN108268332A (en) * | 2017-08-10 | 2018-07-10 | 广州神马移动信息科技有限公司 | Webpage abnormality monitoring method, equipment and system |
CN110110274A (en) * | 2019-05-17 | 2019-08-09 | 极智(上海)企业管理咨询有限公司 | A kind of browser multi-page Message Processing distribution method |
CN112685211A (en) * | 2021-01-04 | 2021-04-20 | 北京金山云网络技术有限公司 | Error information display method and device, electronic equipment and medium |
CN113542229A (en) * | 2021-06-21 | 2021-10-22 | 浙大城市学院 | Method for secure non-homologous page cross-domain communication |
CN114116443A (en) * | 2021-07-06 | 2022-03-01 | 深圳点猫科技有限公司 | Page data transmission method, device, system and medium |
CN115994280A (en) * | 2023-03-23 | 2023-04-21 | 浙江数新网络有限公司 | Browser tab communication method, system, electronic equipment and storage medium |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101772780A (en) * | 2007-05-28 | 2010-07-07 | 谷歌公司 | Inter-domain communication |
EP2225869A2 (en) * | 2007-11-23 | 2010-09-08 | Koninklijke Philips Electronics N.V. | Co-browsing (java) scripted html documents |
CN102307220A (en) * | 2011-03-18 | 2012-01-04 | 北京神州数码思特奇信息技术股份有限公司 | Cross-domain webpage information interaction method |
CN102567125A (en) * | 2011-12-28 | 2012-07-11 | 中标软件有限公司 | Method for realizing communication between browser pages |
CN103095762A (en) * | 2011-11-02 | 2013-05-08 | 腾讯科技(深圳)有限公司 | Web page cross-domain communication method and device |
-
2014
- 2014-12-19 CN CN201410814706.1A patent/CN104410722A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101772780A (en) * | 2007-05-28 | 2010-07-07 | 谷歌公司 | Inter-domain communication |
EP2225869A2 (en) * | 2007-11-23 | 2010-09-08 | Koninklijke Philips Electronics N.V. | Co-browsing (java) scripted html documents |
CN102307220A (en) * | 2011-03-18 | 2012-01-04 | 北京神州数码思特奇信息技术股份有限公司 | Cross-domain webpage information interaction method |
CN103095762A (en) * | 2011-11-02 | 2013-05-08 | 腾讯科技(深圳)有限公司 | Web page cross-domain communication method and device |
CN102567125A (en) * | 2011-12-28 | 2012-07-11 | 中标软件有限公司 | Method for realizing communication between browser pages |
Cited By (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105677536A (en) * | 2016-01-08 | 2016-06-15 | 上海斐讯数据通信技术有限公司 | Implementing method for task messages and task system for implementing task messages |
CN108268332A (en) * | 2017-08-10 | 2018-07-10 | 广州神马移动信息科技有限公司 | Webpage abnormality monitoring method, equipment and system |
CN110110274A (en) * | 2019-05-17 | 2019-08-09 | 极智(上海)企业管理咨询有限公司 | A kind of browser multi-page Message Processing distribution method |
CN112685211A (en) * | 2021-01-04 | 2021-04-20 | 北京金山云网络技术有限公司 | Error information display method and device, electronic equipment and medium |
CN112685211B (en) * | 2021-01-04 | 2024-06-04 | 北京金山云网络技术有限公司 | Error information display method and device, electronic equipment and medium |
CN113542229A (en) * | 2021-06-21 | 2021-10-22 | 浙大城市学院 | Method for secure non-homologous page cross-domain communication |
CN113542229B (en) * | 2021-06-21 | 2023-03-24 | 浙大城市学院 | Method for secure non-homologous page cross-domain communication |
CN114116443A (en) * | 2021-07-06 | 2022-03-01 | 深圳点猫科技有限公司 | Page data transmission method, device, system and medium |
CN115994280A (en) * | 2023-03-23 | 2023-04-21 | 浙江数新网络有限公司 | Browser tab communication method, system, electronic equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN104410722A (en) | Method and system for communication of Web page window objects | |
WO2015143956A1 (en) | Method and apparatus for blocking advertisement in web page | |
US11074312B2 (en) | System and method for dynamic imagery link synchronization and simulating rendering and behavior of content across a multi-client platform | |
CN102724187B (en) | A kind of safety detection method for network address and device | |
CN104301443B (en) | A kind of method and system that end ability interface is called on web page | |
CN110020367B (en) | Page rendering method and device | |
US9129116B1 (en) | System and method for indicating security | |
US9450803B2 (en) | Efficient delivery of content by virtualization of dynamic interaction with the document object model | |
EP2874078A1 (en) | Method to enable cross-origin resource sharing from a webpage inside a private network | |
CN106339309B (en) | Application program testing method, client and system | |
WO2018205918A1 (en) | Webpage monitoring method and apparatus, and storage medium | |
CN103139292A (en) | Method for processing pictures in hyper text transmission protocol (HTTP) proxy and proxy server and system | |
WO2018001124A1 (en) | Webpage file sending method, webpage rendering method and apparatus, and webpage rendering system | |
CN103970760B (en) | A kind of web-page requests processing method and processing device | |
CN105262629A (en) | Method and system enabling WebSocket in network management system to push alarm information | |
US9785710B2 (en) | Automatic crawling of encoded dynamic URLs | |
CN104954894A (en) | Video traffic guiding method and device as well as electronic equipment | |
CN104144206A (en) | Method, system and device for loading interface | |
CN113900834B (en) | Data processing method, device, equipment and storage medium based on Internet of things technology | |
CN110020304A (en) | A kind of method and apparatus of loading page | |
US20140052851A1 (en) | Systems and methods for discovering sources of online content | |
US11431634B2 (en) | Client device and resource manager load sharing | |
CN103488508B (en) | Browser working method, browser and terminal equipment | |
US20150106689A1 (en) | Web server system, web server and web provding method | |
CN104572914A (en) | Method and device for intercepting advertisements of double-core browser |
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 | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20150311 |
|
RJ01 | Rejection of invention patent application after publication |