0

I have been trying to access a html source file through iframe. It works fine and I can see the source, but my external JavaScript file doesn't work through the iframe.

So far this is what I have for accessing the HTML file.

<iframe src="Example.html">
     <p>Your browser does not support iframes.</p>
</iframe>

and then in Example.html I have:

<script src="SpinScript.js"></script>

This works if I run the HTML file in any browser, but not through the iframe

In this HTML file I have other JavaScript elements but they are just written in this document and they work fine through the iframe.

What I'm wondering is if have to re-establish where the JavaScript file is in the iframe?

Hope that all makes sense and thanks for your time.

Volker E.
  • 5,911
  • 11
  • 47
  • 64
  • possible duplicate of [Invoking JavaScript code in an iframe from the parent page](http://stackoverflow.com/questions/251420/invoking-javascript-code-in-an-iframe-from-the-parent-page) – André Dion May 20 '14 at 11:43
  • The iframe is only a container for the content. I don't need to call any functions through the iFrame. The SpinScript just allows user input. – user3656313 May 20 '14 at 12:03

1 Answers1

1

Your parent window and iframe should be from the same source (url), then you can use window.frames[framename] to get window object in iframe

  • Wouldn't that be if I wanted to call a function from the content in the iFrame from the page the iframe was created. – user3656313 May 20 '14 at 12:01