{"id":2991,"date":"2014-03-13T01:30:52","date_gmt":"2014-03-13T01:30:52","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/13\/problem-about-postmessage-collection-of-common-programming-errors\/"},"modified":"2014-03-13T01:30:52","modified_gmt":"2014-03-13T01:30:52","slug":"problem-about-postmessage-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/13\/problem-about-postmessage-collection-of-common-programming-errors\/","title":{"rendered":"problem about postmessage-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/89841cf57849bbe957c155d3d68252f6?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJason<br \/>\njavascript jquery postmessage<br \/>\nOdd issue. I am using jQuery .postMessage() to send messages from a secure &lt;iframe&gt; to the parent. Specifically I am sending a URL and have confirmed that the parent is receiving the URL &#8211; however, when I use try to set window.location to that URL, nothing happens.The sent url:http:\/\/mydomain.com\/shop\/507870?nav=ln-474#\/shop\/507870?gnrefine=1*COLOR_FAMILY*Brown%5E1*CLSR_TYP*Lace-Up%5EThe actual url:http:\/\/mydomain.com\/shop\/507870?nav=ln-474#\/shop\/507870?gnrefine=1*COLOR_FAMILY*Brown%5E1*CL<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/8348bcf40f55bc5818651824369caff1?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nSoner G\u00f6n\u00fcl<br \/>\nc# postmessage<br \/>\nI&#8217;m having a funny ol&#8217; time with PostMessage, wondering if anybody could enlighten me.The method below processes the first left click but not the second, I did a bit of messing around and found that using a MessageBox and hitting OK even instantly provides the delay\/release or whatever it is that&#8217;s needed to make the second left click process.public void MouseClick(IntPtr handle) {PostMessage(handle, (uint)WMessages.WM_LBUTTONDOWN, 0, MAKELPARAM(521, 147));PostMessage(handle, (uint)WMessages.WM_<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/eec7e09c7d0731a44e91b403dd0bc347?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nRoman<br \/>\nc# copy postmessage<br \/>\nI need to recieve data from some win application (not mine). Application window can be inactive at this time. Data I need is represented in table, so I am unable to use WM_GETTEXT, WM_COPY because they retrieve text only from texboxes, textareas, etc. I can manually make a selection at this table and all I need is just copy text from this selection by emulation of Ctrl+C to copy data to clipboard. I tried to send that key sequence this wayPostMessage(hwnd, WM_KEYDOWN, 0x11, 0x001D0001); PostMess<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/17622389f557c5fbec16647687b793b0?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nGeray Suinov<br \/>\njavascript jquery internet-explorer-9 postmessage<br \/>\nMy sender function:var parseData = JSON.stringify(requestData);iframe[0].contentWindow.postMessage({ request: parseData, request_id: dataOrign.length &#8211; 1 }, &#8216;*&#8217;);and function of receiving a request:$(window).on(&#8220;message&#8221;, function(e) {var requestData = JSON.parse(e.originalEvent.data.request);}in IE 9 I have this error:0x800a03f6 &#8211; JavaScript runtime error: Invalid character in:var requestData = JSON.parse(e.originalEvent.data.request);In other browsers everything works fine. tell me what the pr<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/cf1b1ffa204cf0dcb173ff527a6cfb53?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nMariusz<br \/>\ndelphi service postmessage<br \/>\nThere is a problem I am unable to solve. I created two service applications in Delphi and tried to post messages within them. Of course, there are no windows in such applications and PostMessage needs a window handle parameter to send a message. Therefore, I created a window handle using the AllocateHWnd(MyMethod: TWndMethod) function and passed, as the &#8216;MyMethod&#8217; parameter, a procedure I want to be called when a message is received. If it was a windowed application, PostMessage() called using t<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/aSqmJ.jpg?s=32&amp;g=1\" \/><br \/>\ndman<br \/>\njavascript json web-worker postmessage<br \/>\nI am using Javascript Web Workers. In the web worker, I have:function makeRequestChat(id) {var jsonObj;var xml = new XMLHttpRequest();xml.open(&#8220;POST&#8221;, &#8220;\/site\/myapp\/&#8221; + id, true);xml.onreadystatechange = function () {if (xml.readyState === 4 &amp;&amp; xml.status === 200){var foo = chatQueues[id];foo.queue = id;var bar = JSON.stringify(foo);self.postMessage(bar);}}xml.send(null); }I am using copy for sending the json string. I get Uncaught Error: SyntaxError: DOM Exception 12 get.js:28 xml.onread<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/81060fe344980bc9a3273a48b8f3e31c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nSF.<br \/>\njavascript memory-leaks postmessage<br \/>\nI have a page that may work as a standalone webpage or within a special &#8220;watchdog frame&#8221; to which it would be sending messages periodically using window.top.postMessage(&#8216;message&#8217;, &#8216;*&#8217;);The problem is if the page is loaded as standalone webpage, there will be nothing to capture these messages. Users can be expected to hold that page open for hours or even days at a time.Do these uncaught messages just vanish without a trace, or do they get queued or something like that, leaking the memory?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/75ffddfe141906b9e4fca7c6b44c681e?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\narkanciscan<br \/>\njavascript postmessage web-worker worker domexception<br \/>\nWhen writing the onmessage callback for a Web Worker I get an &#8220;Uncaught Error: SYNTAX_ERR: DOM Exception 12&#8221; in my console when I try to send another postMessage().var w = new Worker(url); w.onmessage = function(e) {if(e.data.msg==&#8217;validate&#8217;){if(validateWork(e.data.wrk)){postMessage(&#8216;proceed&#8217;);}} }<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/f2fc8bb759a3fb62b4392bb30880cad0?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nLoko Web Design<br \/>\njavascript jquery iframe data postmessage<br \/>\nI&#8217;m using Josh Fraser&#8217;s Backwards compatible window.postMessage() (http:\/\/www.onlineaspect.com\/2010\/01\/15\/backwards-compatible-postmessage) and I&#8217;m having trouble.I have 2 iframes on a page and both iframes send different data to the same parent page. In other words, there are 2 XD.receivemessage functions getting 2 different messages from 2 different iframes. Here&#8217;s a shortened version of my code:&lt;iframe id=&#8221;IFRAME1&#8243; src=&#8221;https:\/\/www.DOMAIN.com\/PAGENAMEFIRST.php&#8221;&gt;&lt;\/iframe&gt; &lt;ifram<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/e1ba853830b818de02de4de800d3c9da?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\njuanpastas<br \/>\ngoogle-chrome postmessage<br \/>\nWith tampermonkey I am running this Javascript inside an iframe in my page:document.addEventListener(&#8220;message&#8221;, function(e){console.log(&#8216;asd&#8217;); }, false);This way I could receive messages from parent window. I am using jQuery Mobile and have this HTML:&lt;div data-role=&#8221;page&#8221; data-url=&#8221;\/scraps\/new?for=http:\/\/en.wikipedia.org\/wiki\/List_of_hotels_in_Australia&#8221; tabindex=&#8221;0&#8243; class=&#8221;ui-page ui-body-c ui-page-active&#8221; style=&#8221;min-height: 258px;&#8221;&gt;&lt;p class=&#8221;notice&#8221;&gt;&lt;\/p&gt;&lt;p class=&#8221;alert&#8221;&amp;g<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/8176f83adc0ac8c6bc8fbddb51e55339?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nKarthik<br \/>\njavascript firefox iframe postmessage<br \/>\nI have an iframe and want to send data from the iframe to the parent window.Inside the js code of the iframe, I have the following statementwindow.parent.postMessage(&#8216;hello&#8217;, &#8216;*&#8217;);The corresponding message handler in the parent window is as follows$(window).bind(&#8216;message&#8217;, function (event) {console.log(event.data);console.log(event.origin);console.log(event.source);console.log(&#8216;received&#8217;); });I am loading the code from localhost and the iframe source is also loaded from localhost. I am running t<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/a81dce15032b3cf8b00efd8c2a059099?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nkidata<br \/>\njquery iframe jquery-plugins postmessage<br \/>\ni&#8217;m using Iframe Height Jquery Plugin (Version 1.2.1) to re-size an iframe with dynamic contents.The iframe re-sizes correctly when it&#8217;s loaded. Now i got some ui-tabs in the content, with different heights and i want to resize the iframe when a tab is selected.Calling again jQuery.iframeHeightExternal(); in the iframe content returns only undefined and nothing happens.Calling again jQuery(&#8216;#iframe-box&#8217;).iframeHeight(); in the top-frame resizes correctly. But i need it resizing when the iframe-c<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/graph.facebook.com\/740463549\/picture?type=large\" \/><br \/>\nMickey Bradshaw<br \/>\nc# javascript pdf postmessage axacropdf<br \/>\nI have a pdf opened in an AxAcroPDF control and am trying to capture a posted message from JS in the pdf. Here is my javascript code&#8230;.try {app.alert(this.hostContainer);var x = new Array();x[0] = &#8220;Hello&#8221;;this.hostContainer.postMessage(x); } catch (err) {app.alert(err.message) }The first message that pops up says &#8220;undefined&#8221;. The second message (through error catching) says &#8220;this.hostContainer has no properties&#8221;What am I missing? Do I have to somehow assign the AxAcroPDF control to be the ho<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/533fbf26cad8c911470f56b85c9c845e?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nPatrick Thill<br \/>\niframe internet-explorer-8 postmessage<br \/>\nI have a web application with an iframe that needs to communicate with its hosting page. The iframe and the host are on different domains and protocols (the iframe is https, the main page http). I use postMessage to get a small bit of state (user tracking) from the outer page into the iframe.When the iframe is loaded, it sends a short message out to the top page to ask for the visitorid:if ($.w.top != $.w) $.f.postMessage($.w.top, &#8216;Get visitorId&#8217;);($.f.postMessage(w, m) is just a wrapper aroun<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/1039e1507d48c7f1b26f56f672e4b646?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nwoahman<br \/>\njquery postmessage<br \/>\nI&#8217;m trying to learn jQuery, I want to make a simple postMessage client. Is it possible to wrap it in jquery? The first alert works, but the second does not.I&#8217;m trying to modify this code: http:\/\/austinchau.blogspot.com\/2008\/11\/html5-cross-document-messaging.html$(document).ready(function() {$(&#8216;#submit_button&#8217;).click(function() {var data = $(&#8216;#message&#8217;).val();window.postMessage(&#8216;1st&#8217; + data);alert(data);});var onmessage = function(e) {var data = e.data;var origin = e.origin;document.getElementBy<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/1418ba3d9ca124ff55e11f8050682aa6?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nNewtang<br \/>\njavascript google-chrome google-chrome-extension postmessage<br \/>\nSo, I have a page on DomainA, and, using a Chrome extension, I&#8217;m injecting some javascript that inserts iframe that points to DomainB.$(&#8220;body&#8221;).append(&#8220;&lt;iframe id=&#8217;someFrame&#8217; src=&#8217;http:\/\/www.domainB.com&#8217; width=&#8217;300&#8242; height=&#8217;800&#8242;&gt;&lt;\/iframe&gt;&#8221;);I also inject a some javascript into DomainA that attempts to get the iframe&#8217;s contentWindow. I want to use the HTML5 postMessage api on it.$(&#8220;body&#8221;).append(&#8220;&lt;a class=&#8217;myLink&#8217;&gt;Post Message&lt;\/a&gt;&#8221;); $(&#8220;.myLink&#8221;).click(function(){var fra<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/bbd934c38bbcb0918e4c107b0399f87e?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nDraco<br \/>\njavascript html5 cross-browser postmessage<br \/>\nI wrote a content script that injects an iframe to any website (therefore different domain). I need the parent website to send some information to the child iframe, however I couldn&#8217;t find a way to do it. The codevar targetFrame = $(&#8216;#myIframe&#8217;)[0]; targetFrame.contentWindow.postMessage(&#8216;the message&#8217;, &#8216;*&#8217;);Doesn&#8217;t work somehow and i get a Cannot call method &#8216;postMessage&#8217; of undefined error. But then when I tried the same code directly in Chrome&#8217;s console, it worked.I had no trouble sending a pos<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/136b02513fa9c2df1d783d8bdb0931d0?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nstefan<br \/>\njquery html5 postmessage<br \/>\nWhen I use jquery event listener to handle message event, like below:$(window).on(&#8216;message&#8217;, function(e) {var data = e.data; \/\/ data = undefined });data is undefined! I&#8217;m sure that I have passed data to current window. Because if I use &#8220;addEventListener&#8221;, everything goes well!So, what&#8217;s the problem?thanks!<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/1074f0a031cca12280359231a87662af?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nEric<br \/>\njavascript postmessage<br \/>\nI&#8217;ve got a webpage that won&#8217;t work properly if postMessage is not available. I&#8217;d like to use a simple:if (window.postMessage === undefined) {\/\/alert the user }Are there any unforeseeable issues with this approach?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/81e2571a8c5fa16559db242ff95af574?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nambrex<br \/>\njavascript html5 iframe postmessage<br \/>\nI am trying to do cross-domain communication using postMessage between a page (on example1.com) and an iframe on the same page that is on example2.comWhen the iframe is done loading, it sends a postMessage to the parent page using the following command:parent.postMessage(&#8216;hello parent&#8217;, &#8216;http:\/\/example1.com&#8217;); \/\/this command worksIn the event handler for postMessage in the parent page (on example1.com), I send a response back to the child page (example2.com) using the following function:\/\/this f<\/li>\n<\/ul>\n<p>Web site is in building<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Jason javascript jquery postmessage Odd issue. I am using jQuery .postMessage() to send messages from a secure &lt;iframe&gt; to the parent. Specifically I am sending a URL and have confirmed that the parent is receiving the URL &#8211; however, when I use try to set window.location to that URL, nothing happens.The sent url:http:\/\/mydomain.com\/shop\/507870?nav=ln-474#\/shop\/507870?gnrefine=1*COLOR_FAMILY*Brown%5E1*CLSR_TYP*Lace-Up%5EThe actual url:http:\/\/mydomain.com\/shop\/507870?nav=ln-474#\/shop\/507870?gnrefine=1*COLOR_FAMILY*Brown%5E1*CL [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2991","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2991","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2991"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2991\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2991"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2991"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2991"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}