0

I'm creating a graph using d3 that will be embedded as an iFrame inside of another html page, which is generated by captivate.

This graph will display different information based on a variable that exists in the parent page.

Additionally, button clicks on the parent page need to call functions within the iframe.

My current solution is to give a reference to a function within my iframe to the parent, which it uses in the buttons' onclick attributes. This works fine running on my localhost, but fails when running offline. Is there some way I can do this programatically without changing settings?

I would like the production version of this to both run online, or locally on a user's machine.

The error I'm getting is:

Uncaught SecurityError: Blocked a frame with origin "null" from accessing a frame with origin "null". Protocols, domains, and ports must match.

The offending line (inside the iframe) is:

window.parent.Test = CaptivateTest1;

The whole parent (a placeholder for now):

<!DOCTYPE html>
<html>
    <head>
        <title></title>
    </head>

    <body>
        <iframe src="Graph.html" width="700px" height="700px"></iframe>
        <input type="button" onclick="Test()"/>
    </body>
</html>
JEJoll
  • 547
  • 1
  • 6
  • 20
  • What do you mean by locally on a users machine? Like on a web server or just as a file? – Peter Dempsey Sep 12 '16 at 18:02
  • 1
    The concensus [here](http://stackoverflow.com/questions/17950598/using-iframe-with-local-files-in-chrome) is that you can't do what you want without a web-server. – Mark Sep 12 '16 at 18:04
  • @toggy-tog-togs From a file. – JEJoll Sep 12 '16 at 20:55
  • @JEJoll that is most likely causing the issue. Try with a webserver to see if the results are any different. – Peter Dempsey Sep 12 '16 at 21:26
  • Thanks @toggy-tog-togs. However, I've already got it working from XAMPP. I need this to work in a purely offline solution (no web-server, etc.). – JEJoll Sep 13 '16 at 08:54
  • @JEJoll You will not be able to. This occurs because the browser does not allow you to do such a thing as it is not on a domain. – Peter Dempsey Sep 13 '16 at 09:03

0 Answers0