Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to Send Data Cross Domain using postMessage?
    primarykey
    data
    text
    <p>I have an uploadify script in an iFrame which is on another domain. I am attempting to send the file upload <code>data</code> to the page on which the iFrame is embedded on. </p> <p>I have the following code in a iFrame (uploadify script): </p> <pre><code>$('#file_upload').uploadify({ //JS CODE 'onUploadSuccess' : function(file, data, response) { data //data is what must be passed from the iFrame to the script on another site } }); </code></pre> <p><code>data</code> is what must be passed to the following script on another domain: </p> <pre><code>var myframe, nestedFrame; myFrame = $('#editorf').contents().find('body'); nestedFrame = myFrame.find('#re_contentIframe').contents().find('body'); nestedFrame.append('data'); //data should be replaced with the information from the iFrame </code></pre> <p>I did attempt the following code:</p> <p><em>iFrame Code - Page B</em> </p> <pre><code>$('#file_upload').uploadify({ //JS CODE for UPLOADIFY 'onUploadSuccess' : function(file, data, response) { window.postMessage('http://iframe-domain.net/uploads/' + data,'http://iframe-domain.net'); } }); </code></pre> <p><em>Receiving Page Code - Page A</em></p> <pre><code>$(function() { window.addEventListener('message', receiver, false); function receiver(e){ if (e.origin == 'http://iframe-domain.net'){ var myframe, nestedFrame; myFrame = $('#editorf').contents().find('body'); nestedFrame = myFrame.find('#re_contentIframe').contents().find('body'); nestedFrame.append(e.data); } } }); </code></pre> <p>This doesn't work. I do receive this error message: </p> <pre><code>Error: Permission denied to access property 'toString' ...a);if(Z){var Y=0;(function(){if(typeof Z.GetVariable!=D){var ab=Z.GetVariable("$... jquery.uploadify.js (line 17) </code></pre> <p>The uploadify Script does work as the file is uploaded but it doesn't appear to pass the data to the page. I am not convinced this error is the reason the page isn't working. </p> <p>How do I do this?</p> <p><em>EDIT</em></p> <p>To better explain here is an example: </p> <p>A person goes to Page A (the main page). On Page A an iFrame is embedded on that page. Inside the iFrame is an uploadify script to allow users to upload a file.</p> <p>A person uploads a file the uploadify script returns the file name. Example: <code>528050f030522.jpg</code>. Once the uploadify script has this information it should send it to Page A's script which then runs and inserts the file name into the page.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload