I would like to display an HTML document that has been loaded from a URL (I’m aware of the security implications).
Currently I see two options for this:
- create an
iframeand display the content from the URL
- download the HTML and set it as
innerHTML. Since my app uses React, this means calling
I’ve implemented both and they work fine.
But so far this is just a React web app. Once everything is more or less in place I would like to migrate it to Capacitor with Ionic.
At that point, I would then like to download the HTML and store it locally, to allow the app to work offline.
How would this work with the iframe? Is it possible to pass a local URI for the source? The Capacitor Filesystem API would make it easy to get a URI, but I don’t understand how that interfaces with the web code inside of the app.
I’m asking because I’m unsure how to continue with the prototyping. I feel like the
iframe is a cleaner approach. But
dangerouslySetInnerHTML would work just the same with HTML that I’ve loaded from a local file.