staram się komunikować między iframe dziecka i jego rodzica stosując następujące wtyczki:iframe wiadomości domeny krzyż z pluginem jQuery postMessage
http://benalman.com/projects/jquery-postmessage-plugin/
mogę pójść za przykładem i wysyłać wiadomości od dziecka, rodzic, ale nie w inny sposób i naprawdę muszę być w stanie komunikować się w obie strony.
Kod na dominującej jest następujący:
var origin = document.location.protocol + '//' + document.location.host,
src = origin + '/Custom/Ui/Baseline/html/iframe-data-cash.htm#' + encodeURIComponent(document.location.href);
$(function() {
var $holder = $('#iframe'),
height,
$iframe = $('<iframe src="' + src + '" id="data-cash-iframe" width="100%" scrolling="no" allowtransparency="true" seamless="seamless" frameborder="0" marginheight="0" marginwidth="0"></iframe>');
// append iframe to DOM
$holder.append($iframe);
});
$(window).load(function() {
$.postMessage(
'hello world',
src,
parent.document.getElementById('data-cash-iframe').contentWindow
);
});
I kod na dziecko jest w następujący sposób:
$(function() {
var parentURL = decodeURIComponent(document.location.hash.replace(/^#/, ''));
$.receiveMessage(
function (e) {
alert(e.data);
},
parentURL
);
});
Naprawdę nie mogę zrozumieć, dlaczego to nie działa i jestem zdesperowany potrzeba pomocy!