i have 2 sites, and i want to use javascriptpostMessage
between them.
on my main site i write the following code in an emty html file :
<html>
<script>
window.addEventListener("message",listener_,false);
function listener_(event) {
console.log('ok!');
<html>
<script>
window.addEventListener("message",listener_,false);
function listener_(event) {
console.log('ok!');
//console.log(event);
//console.log(event.data);
}
</script>
</html>
and in other site that i want to call the postmessage from the i write the following code:
<script type="text/javascript">
window.onload = function() {
testfunction();
};
function testfunction(){
var childWin = window.open("http://my-main-site.com/indexjava2.html","child");
childWin = postMessage('message','*');
console.log(TipaltiIframeInfo.height);
}
</script>
but it doesn't work after a lot of tries. i mean console.log('ok!'); or console.log(event); console.log(event.data);
doesn't trigger on console of main site,
what to do? thanks
<script>
tag and there is a<html>
tag in script tag. Fix those first.<script>
tag between them. That script tag will cause an error and neither work. Is this just a typo while posting here, or is this what you really have on your page?