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.

2
  • possible duplicate of Invoking JavaScript code in an iframe from the parent page Commented May 20, 2014 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. Commented May 20, 2014 at 12:03

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Wouldn't that be if I wanted to call a function from the content in the iFrame from the page the iframe was created.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.