1

Helly everyone,

I desperately try to call a function inside an Iframe for hours without success.

Here are the two things I have (working on Safari), the parent code:

window.frames['map-frame'].Test();

or

document.getElementById('map-frame').contentWindow.postMessage("test", '*');

The frame code:

window.Test = function ()
 {
  alert("1");
 }

or

window.receiveMessage = function (event)
{
  alert("2");
}
addEventListener("message", receiveMessage);

As I said, it works for both solutions in Safari, but not in Chrome. Both files are on my webserver (I've seen that local calls can be blocked in Chrome). I've tried barely anything I've found on Stackoverflow and Google but nothing do the tricks.

Did anyone ever has the same issue? Anyone knows a tricks or something to try?

Thanks in advance folks

user3316068
  • 47
  • 1
  • 3

1 Answers1

0

https://stackoverflow.com/a/40407241/3316068

This solution from William Littlefield worked for me. Also, make sure your frame is fully loaded before calling a function from it.

Community
  • 1
  • 1
user3316068
  • 47
  • 1
  • 3