How to communicate between iframes on different domains?
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
</head>
<body>
<div>
<iframe id="tc" src="http://www.domain1.com/page1.html">
</iframe>
<iframe id="tf" src="http://www.domain2.com/page1.html">
</iframe>
</div>
<div>
<button onclick="tcget();">Click me</button>
<button onclick="tfget();">Click me</button>
</div>
<script>
function tcget()
{
try
{
alert($('#tc').contents().find('body').html());
}
catch(err)
{
alert(err);
}
}
function tfget()
{
try
{
alert($('#tf').contents().find('body').html());
}
catch(err)
{
alert(err);
}
}
</script>
</body>
</html>
I would like to be able to share content, from each iframe loaded into the same page.
I have looked into window.postMessage
but this does not appear to be able to do it either. My app will be pulling statistics from each iframe
for a Neural Net - I hope that it can be done, security wise it seems that its not something that can be done.