3

What is the best way to use iframe in react application, while having local html file for ifram src.

I need to have an iframe in my react application, but the iframe does not work with my local html file.

function ClusterDetails() {

  return (
    <iframe title='mytitle' src="../../data/index.html" width='500px'  height='500px'></iframe>
  );
}

export default ClusterDetails;

1 Answer 1

5

I found the solution. The source of iframe should be placed in public folder. the src attribute of iframe should be addressed related to public folder.

For example if there is a data folder containing index.html file, in public folder, then the src should be set as 'data/index.html'

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

1 Comment

I get a "Cannot GET" in the iframe when trying this

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.