Reputation: 4540
I want to load a local html file into an iframe element in React. I followed the accepted answer on this question, but it doesn't work.
The folder structure in my project is like below:
Iframe element looks like this:
<iframe
src="../testHTMLFiles/index.html"
height="100%"
width="100%"
frameBorder="0"
/>
What am I missing?
Upvotes: 3
Views: 3831
Reputation: 15841
The iframe src must contain an absolute url:
https://www.example.com/testHTMLFiles/index.html
This is because in your build the file is not avaliable at this position after build and iframe path is resolved as iframe is instanced.
Upvotes: 4