问题
I have a .html document that I need in an <iframe> tag. Let's say it is called FILE.html and is hosted at http://files.net/FILE.html.
So, I write the iframe tag as such:
<iframe src="http://files.net/FILE.html"></iframe>
Instead of the iframe appearing as a nice little box and rendering the html in FILE.html, it instead opens File Explorer and prompts the user to download FILE.html. I don't want them to download it, I just want them to see it rendered on their screen.
So is there a way for me to format it such that the html renders and doesn't download? Can I change the FILE.html, or change the iframe tag, or upload it in a different way?
回答1:
Something about the way that file is being served is telling the browser that it isn't an HTML file that can be displayed. This is probably because its Content-Type header is incorrect, but may also be because the file is being served with a Content-Disposition header that instructs the browser to download it.
Assuming that you have access to the server that this file is being served from, you will need to configure it to use the correct headers. There is no way to override these headers in a frame.
来源:https://stackoverflow.com/questions/34445215/how-to-stop-embedded-html-files-from-downloading